[master] 698a4742e vcc: Plug more insignificant leaks
Nils Goroll
nils.goroll at uplex.de
Sun Jan 10 17:26:06 UTC 2021
commit 698a4742efb8e14f7706fe593a5d4b8774abb63a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sun Jan 10 17:59:32 2021 +0100
vcc: Plug more insignificant leaks
Coverity CID 1362617, CID 1362625, CID 1362626, CID 1362627
diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index 6bfc553b2..361e900c7 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -194,8 +194,10 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
* If the two rules agree, silently ignore it
* XXX: is that counter intuitive ?
*/
- if (aen->not == ae2->not)
+ if (aen->not == ae2->not) {
+ free(aen);
return;
+ }
VSB_cat(tl->sb, "Conflicting ACL entries:\n");
vcc_ErrWhere(tl, ae2->t_addr);
VSB_cat(tl->sb, "vs:\n");
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index c6028deea..af75bbc04 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -149,15 +149,15 @@ vcc_Redef(struct vcc *tl, const char *redef, struct token **t_did,
*/
static void
-vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **name)
+vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **namep)
{
struct fld_spec *fs;
struct token *t_field;
struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
struct token *t_initial = NULL;
- struct vsb *vsb;
- char *retval;
unsigned window, threshold, initial, status;
+ char buf[32];
+ const char *name;
double t;
fs = vcc_FldSpec(tl,
@@ -173,25 +173,21 @@ vcc_ParseProbeSpec(struct vcc *tl, const struct symbol *sym, char **name)
SkipToken(tl, '{');
- vsb = VSB_new_auto();
- AN(vsb);
- if (sym != NULL)
- VSB_cat(vsb, sym->rname);
- else
- VSB_printf(vsb, "vgc_probe__%d", tl->nprobe++);
- AZ(VSB_finish(vsb));
- retval = TlDup(tl, VSB_data(vsb));
- AN(retval);
- VSB_destroy(&vsb);
- if (name != NULL)
- *name = retval;
+ if (sym != NULL) {
+ name = sym->rname;
+ } else {
+ bprintf(buf, "vgc_probe__%d", tl->nprobe++);
+ name = buf;
+ }
+ Fh(tl, 0, "static const struct vrt_backend_probe %s[] = {{\n", name);
+ Fh(tl, 0, "\t.magic = VRT_BACKEND_PROBE_MAGIC,\n");
+ if (namep != NULL)
+ *namep = TlDup(tl, name);
window = 0;
threshold = 0;
initial = 0;
status = 0;
- Fh(tl, 0, "static const struct vrt_backend_probe %s[] = {{\n", retval);
- Fh(tl, 0, "\t.magic = VRT_BACKEND_PROBE_MAGIC,\n");
while (tl->t->tok != '}') {
vcc_IsField(tl, &t_field, fs);
@@ -323,7 +319,7 @@ vcc_ParseProbe(struct vcc *tl)
sym = VCC_HandleSymbol(tl, PROBE, "vgc_probe");
ERRCHK(tl);
AN(sym);
- vcc_ParseProbeSpec(tl, sym, &p);
+ vcc_ParseProbeSpec(tl, sym, NULL);
}
}
@@ -480,6 +476,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == '{') {
vcc_ParseProbeSpec(tl, NULL, &p);
Fb(tl, 0, "\t.probe = %s,\n", p);
+ free(p);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == ID) {
if (vcc_IdIs(tl->t, "default")) {
More information about the varnish-commit
mailing list