[master] 02a9d3d45 Fix double-free introduced by leak plug

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Dec 30 11:01:07 UTC 2019


commit 02a9d3d45006912e06c95398436c9b2d66677ad5
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Dec 30 11:59:03 2019 +0100

    Fix double-free introduced by leak plug
    
    Once all instances of a given test are started all of the remaining
    tests would free the test data structure, we needed another counter
    to keep track of ongoing tests so that only the last one to finish
    would do the single free.

diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index f0b147265..a080de934 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -72,6 +72,7 @@ struct vtc_tst {
 	const char		*filename;
 	char			*script;
 	unsigned		ntodo;
+	unsigned		nwait;
 };
 
 struct vtc_job {
@@ -370,7 +371,8 @@ tst_cb(const struct vev *ve, int what)
 			VEV_Stop(vb, jp->evt);
 			free(jp->evt);
 		}
-		if (jp->tst->ntodo == 0) {
+		jp->tst->nwait--;
+		if (jp->tst->nwait == 0) {
 			free(jp->tst->script);
 			FREE_OBJ(jp->tst);
 		}
@@ -644,6 +646,7 @@ read_file(const char *fn, int ntest)
 	tp->filename = fn;
 	tp->script = p;
 	tp->ntodo = ntest;
+	tp->nwait = ntest;
 	VTAILQ_INSERT_TAIL(&tst_head, tp, list);
 	return (0);
 }


More information about the varnish-commit mailing list