[master] d3d39f563 std.ip: Honor the workspace snapshot/reset contract

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Aug 31 18:41:09 UTC 2020


commit d3d39f563ce6d99a6581cf138c2ff7b5c3cbd703
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Jun 2 16:12:26 2020 +0200

    std.ip: Honor the workspace snapshot/reset contract
    
    Initially caught by wssan from #3320.

diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c
index 3f0b74ea1..84ee9e14a 100644
--- a/lib/libvmod_std/vmod_std_conversions.c
+++ b/lib/libvmod_std/vmod_std_conversions.c
@@ -195,6 +195,7 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a)
 VCL_IP
 vmod_ip(VRT_CTX, struct VARGS(ip) *a)
 {
+	uintptr_t sn;
 	void *p;
 	VCL_IP retval = NULL;
 
@@ -202,6 +203,7 @@ vmod_ip(VRT_CTX, struct VARGS(ip) *a)
 	if (a->valid_fallback)
 		assert(VSA_Sane(a->fallback));
 
+	sn = WS_Snapshot(ctx->ws);
 	p = WS_Alloc(ctx->ws, vsa_suckaddr_len);
 	if (p == NULL) {
 		VRT_fail(ctx, "std.ip: insufficient workspace");
@@ -217,7 +219,7 @@ vmod_ip(VRT_CTX, struct VARGS(ip) *a)
 	if (retval != NULL)
 		return (retval);
 
-	WS_Reset(ctx->ws, (uintptr_t)p);
+	WS_Reset(ctx->ws, sn);
 
 	if (a->valid_fallback)
 		return (a->fallback);


More information about the varnish-commit mailing list