Skip to content
Permalink
Browse files

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).
  • Loading branch information...
mbgrydeland committed Aug 31, 2019
1 parent 63dbc26 commit 374b94331178266da5835c454a853e34ad084ef4
Showing with 4 additions and 1 deletion.
  1. +4 −1 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);

0 comments on commit 374b943

Please sign in to comment.
You can’t perform that action at this time.