[master] 1d23a7335 Correct WS allocation in tlv_string

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Nov 14 10:49:06 UTC 2019


commit 1d23a7335eda7741574e9b680401f5acc2a4d67d
Author: Emmanuel Hocdet <manu at gandi.net>
Date:   Thu Nov 14 11:14:07 2019 +0100

    Correct WS allocation in tlv_string
    
    Fixes #3131

diff --git a/lib/libvmod_proxy/vmod_proxy.c b/lib/libvmod_proxy/vmod_proxy.c
index 58f2db295..222de9c53 100644
--- a/lib/libvmod_proxy/vmod_proxy.c
+++ b/lib/libvmod_proxy/vmod_proxy.c
@@ -105,12 +105,13 @@ tlv_string(VRT_CTX, int tlv)
 
 	if (VPX_tlv(ctx->req, tlv, (void **)&dst, &len))
 		return (NULL);
-	if (!WS_ReserveSize(ctx->ws, len+1))
+	d = WS_Alloc(ctx->ws, len+1);
+	if (d == NULL) {
+		VRT_fail(ctx, "proxy.TLV: out of workspace");
 		return (NULL);
-	d = ctx->ws->f;
+	}
 	memcpy(d, dst, len);
 	d[len] = '\0';
-	WS_Release(ctx->ws, len+1);
 	return (d);
 }
 


More information about the varnish-commit mailing list