[6.0] 9bf79d4ec Don't waste workspace on format failure

Reza Naghibi reza at naghibi.com
Wed Aug 19 13:14:06 UTC 2020


commit 9bf79d4ec4e961d6100871e0185544f2d6de7fb6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed May 6 15:00:38 2020 +0200

    Don't waste workspace on format failure

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 8eed99e4c..20d855478 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -626,13 +626,17 @@ VCL_STRING v_matchproto_()
 VRT_TIME_string(VRT_CTX, VCL_TIME t)
 {
 	char *p;
+	uintptr_t snapshot;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+	snapshot = WS_Snapshot(ctx->ws);
 	p = WS_Alloc(ctx->ws, VTIM_FORMAT_SIZE);
 	if (p != NULL) {
 		VTIM_format(t, p);
-		if (*p == '\0')
+		if (*p == '\0') {
 			p = NULL;
+			WS_Reset(ctx->ws, snapshot);
+		}
 	}
 	return (p);
 }


More information about the varnish-commit mailing list