From: Michal Privoznik Date: Wed, 5 Apr 2017 07:59:25 +0000 (+0200) Subject: virStorageSourceClear: Don't leave dangling pointers behind X-Git-Tag: v3.3.0-rc1~274 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=349badbffd50f86580884b29fdfa7ad6ea082c2e;p=thirdparty%2Flibvirt.git virStorageSourceClear: Don't leave dangling pointers behind Imagine that this function is called twice over the same disk source. While in the first run all allocated memory is freed, not all pointers are set to NULL (e.g. def->srcpool). So when called again, these poitners are freed again resulting in double free. Signed-off-by: Michal Privoznik --- diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a51622affe..94a77ce862 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2274,6 +2274,8 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->nodeformat); virStorageSourceBackingStoreClear(def); + + memset(def, 0, sizeof(*def)); }