[master] ad1eb2f Fix memory leak I just introduced.

Poul-Henning Kamp phk at varnish-cache.org
Fri Aug 9 13:55:17 CEST 2013


commit ad1eb2fd1877cd5f6d444faae8d9730dc5e7eb55
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Aug 9 11:54:49 2013 +0000

    Fix memory leak I just introduced.
    
    Spotted by:	Federico Schwindt

diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c
index b5649b6..651a77c 100644
--- a/lib/libvmod_std/vmod_std_conversions.c
+++ b/lib/libvmod_std/vmod_std_conversions.c
@@ -126,7 +126,7 @@ vmod_integer(const struct vrt_ctx *ctx, const char *p, VCL_INT i)
 VCL_IP
 vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d)
 {
-	struct addrinfo hints, *res0;
+	struct addrinfo hints, *res0 = NULL;
 	const struct addrinfo *res;
 	int error;
 	char *p;
@@ -154,5 +154,7 @@ vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d)
 	p = WS_Alloc(ctx->ws, VSA_Len(d));
 	AN(p);
 	memcpy(p, d, VSA_Len(d));
+	if (res0 != NULL)
+		freeaddrinfo(res0);
 	return (p);
 }



More information about the varnish-commit mailing list