[master] cffcca5 Plug some leaks

Federico G. Schwindt fgsch at lodoss.net
Fri Apr 13 09:31:15 UTC 2018


commit cffcca5556cd06fec5304e7e20874338d4b5ffb3
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Fri Apr 13 10:16:32 2018 +0100

    Plug some leaks

diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index d4e45c7..c6c5897 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -167,7 +167,7 @@ macro_undef(struct vtclog *vl, const char *instance, const char *name)
 		VTAILQ_REMOVE(&macro_list, m, list);
 		free(m->name);
 		free(m->val);
-		free(m);
+		FREE_OBJ(m);
 	}
 	AZ(pthread_mutex_unlock(&macro_mtx));
 }
diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c
index 663a363..8d4118f 100644
--- a/bin/varnishtest/vtc_haproxy.c
+++ b/bin/varnishtest/vtc_haproxy.c
@@ -56,7 +56,7 @@ struct haproxy {
 	struct vtclog		*vl;
 	VTAILQ_ENTRY(haproxy)	list;
 
-	char			*filename;
+	const char		*filename;
 	struct vsb		*args;
 	int			opt_worker;
 	int			opt_daemon;
@@ -72,7 +72,7 @@ struct haproxy {
 	int			expect_signal;
 	int			its_dead_jim;
 
-	const char		*cli_fn;
+	char			*cli_fn;
 
 	char			*workdir;
 	struct vsb		*msgs;
@@ -152,7 +152,7 @@ haproxy_new(const char *name)
 
 	h->filename = getenv(HAPROXY_PROGRAM_ENV_VAR);
 	if (h->filename == NULL)
-		REPLACE(h->filename, "haproxy");
+		h->filename = "haproxy";
 
 	bprintf(buf, "${tmpdir}/%s", name);
 	vsb = macro_expand(h->vl, buf);
@@ -196,6 +196,9 @@ haproxy_delete(struct haproxy *h)
 
 	free(h->name);
 	free(h->workdir);
+	free(h->cli_fn);
+	free(h->cfg_fn);
+	free(h->pid_fn);
 	VSB_destroy(&h->args);
 
 	/* XXX: MEMLEAK (?) */
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 0634d66..2c0b761 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -884,6 +884,7 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp,
 			}
 		} else if (!strcmp(*av, "-bodylen")) {
 			assert(body == nullbody);
+			free(body);
 			body = synth_body(av[1], 0);
 			bodylen = strlen(body);
 			av++;
@@ -895,13 +896,16 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp,
 			av++;
 		} else if (!strcmp(*av, "-gziplen")) {
 			assert(body == nullbody);
+			free(body);
 			b = synth_body(av[1], 1);
 			gzip_body(hp, b, &body, &bodylen);
+			free(b);
 			VSB_printf(hp->vsb, "Content-Encoding: gzip%s", nl);
 			// vtc_hexdump(hp->vl, 4, "gzip", (void*)body, bodylen);
 			av++;
 		} else if (!strcmp(*av, "-gzipbody")) {
 			assert(body == nullbody);
+			free(body);
 			gzip_body(hp, av[1], &body, &bodylen);
 			VSB_printf(hp->vsb, "Content-Encoding: gzip%s", nl);
 			// vtc_hexdump(hp->vl, 4, "gzip", (void*)body, bodylen);
@@ -1911,7 +1915,8 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd,
 	free(hp->rxbuf);
 	free(hp->rem_ip);
 	free(hp->rem_port);
-	free(hp);
+	free(hp->rem_path);
+	FREE_OBJ(hp);
 	return (retval);
 }
 
diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index cbb3c07..735b747 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -191,6 +191,7 @@ logexp_delete(struct logexp *le)
 	AZ(le->vslq);
 	logexp_delete_tests(le);
 	free(le->name);
+	free(le->vname);
 	free(le->query);
 	VSM_Destroy(&le->vsm);
 	FREE_OBJ(le);
diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c
index a3f920d..af6da00 100644
--- a/bin/varnishtest/vtc_process.c
+++ b/bin/varnishtest/vtc_process.c
@@ -386,6 +386,7 @@ process_new(const char *name)
 static void
 process_delete(struct process *p)
 {
+	int i;
 
 	CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC);
 	AZ(pthread_mutex_destroy(&p->mtx));
@@ -401,6 +402,10 @@ process_delete(struct process *p)
 	 * to the test's tmpdir.
 	 */
 
+	for (i = 0; i < p->nlin; i++)
+		free(p->vram[i]);
+	free(p->vram);
+
 	/* XXX: MEMLEAK (?) */
 	FREE_OBJ(p);
 }


More information about the varnish-commit mailing list