[master] 6b1305fa8 smd: Plug inconsequential leak

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jun 27 07:08:08 UTC 2022

commit 6b1305fa87fd0d8ee74c7c68b88e035a3aef02fa
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jun 27 09:00:03 2022 +0200

    smd: Plug inconsequential leak
    The debug stevedore only acts as a wrapper around the malloc storage, so
    it proxies its initialization method. The allocation of av isn't tracked
    so it leaks when it runs out of scope, along with the copies of values
    assigned to the array.
    Since a reference to aav is kept in stevedore::av, we can safely pass
    direct references to arguments to the underlying malloc storage instead
    of copies.
    Spotted by asan.

diff --git a/bin/varnishd/storage/storage_debug.c b/bin/varnishd/storage/storage_debug.c
index 1ab497e50..9a3360a42 100644
--- a/bin/varnishd/storage/storage_debug.c
+++ b/bin/varnishd/storage/storage_debug.c
@@ -80,7 +80,7 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 			methods->objgetspace = smd_lsp_getspace;
-		REPLACE(av[ac], aav[i]);
+		av[ac] = aav[i];
 	assert(ac >= 0);
@@ -88,6 +88,7 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 	sma_stevedore.init(parent, ac, av);
+	free(av);
 const struct stevedore smd_stevedore = {

More information about the varnish-commit mailing list