From: Laine Stump Date: Mon, 18 Mar 2013 20:04:11 +0000 (-0400) Subject: storage: fix unlikely memory leak in rbd backend X-Git-Tag: v1.0.4-rc1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57f39e03ff4ee23e7b9bd1f4b90d7b6f965fa910;p=thirdparty%2Flibvirt.git storage: fix unlikely memory leak in rbd backend virStorageBackendRBDRefreshPool() first allocates an array big enough to hold 1024 names, then calls rbd_list(), which returns ERANGE if the array isn't big enough. When that happens, the VIR_ALLOC_N is called again with a larger size. Unfortunately, the original array isn't freed before allocating a new one. --- diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 8a0e517502..e815192c22 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -317,6 +317,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_WARN("%s", _("A problem occurred while listing RBD images")); goto cleanup; } + VIR_FREE(names); } for (i = 0, name = names; name < names + max_size; i++) {