[master] 374b94331 Sprinkle CHECK_OBJ_NOTNULL on struct vsm_seg

Martin Blix Grydeland martin at varnish-software.com
Mon Sep 9 08:23:06 UTC 2019


commit 374b94331178266da5835c454a853e34ad084ef4
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Sat Aug 31 12:43:39 2019 +0200

    Sprinkle CHECK_OBJ_NOTNULL on struct vsm_seg
    
    Several places in the code lacked checking that these were still valid
    objects (ie not free'd).

diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index a1961de8d..29be668ef 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -537,7 +537,7 @@ vsm_vlu_plus(struct vsm *vd, struct vsm_set *vs, const char *line)
 			VTAILQ_INSERT_TAIL(&vs->clusters, vg, clist);
 		} else if (*vg->av[2] != '0') {
 			vg->cluster = vsm_findcluster(vs, vg->av[1]);
-			AN(vg->cluster);
+			CHECK_OBJ_NOTNULL(vg->cluster, VSM_SEG_MAGIC);
 		}
 	}
 	return (0);
@@ -924,6 +924,7 @@ VSM_Map(struct vsm *vd, struct vsm_fantom *vf)
 		return (0);
 	}
 
+	CHECK_OBJ_NOTNULL(vgc, VSM_SEG_MAGIC);
 	assert(vgc->flags & VSM_FLAG_CLUSTER);
 	assert(vg->s == NULL);
 	assert(vg->sz == 0);
@@ -964,6 +965,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
 	vg = vsm_findseg(vd, vf);
 	if (vg == NULL)
 		return (vsm_diag(vd, "VSM_Unmap: bad fantom"));
+	CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC);
 	assert(vg->refs > 0);
 	vg->refs--;
 	vf->b = NULL;
@@ -972,6 +974,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
 		return (0);
 
 	if (vg->cluster) {
+		CHECK_OBJ_NOTNULL(vg->cluster, VSM_SEG_MAGIC);
 		assert(vg->s == NULL);
 		assert(vg->sz == 0);
 		assert(vg->cluster->refs > 0);


More information about the varnish-commit mailing list