[master] 647e7fa Fix a theoretical resource leak spotted by Coverity: If we are out of malloc space: we leak memory while we collapse.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jan 19 09:13:34 CET 2015


commit 647e7fa32f333989289fdbd0b3beaf6d75ce881c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 19 08:12:24 2015 +0000

    Fix a theoretical resource leak spotted by Coverity:  If we are out of
    malloc space: we leak memory while we collapse.

diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index bd6c932..6cf6370 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -288,8 +288,10 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
 	if (act == VDP_INIT) {
 		vg = VGZ_NewUngzip(req->vsl, "U D -");
 		AN(vg);
-		if (vgz_getmbuf(vg))
+		if (vgz_getmbuf(vg)) {
+			(void)VGZ_Destroy(&vg);
 			return (-1);
+		}
 		VGZ_Obuf(vg, vg->m_buf, vg->m_sz);
 		*priv = vg;
 



More information about the varnish-commit mailing list