[libvirt] [PATCH] virStoragePoolSourceListNewSource: avoid unconditional leak

Jim Meyering jim at meyering.net
Tue Feb 2 19:00:59 UTC 2010


The buffer allocated by VIR_ALLOC here is never used, and
the sole pointer to it is overwritten by this stmt:

     source = &list->sources[list->nsources++];


>From 52cf50def236ab61298ebbba39fcaf89d440f4ec Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 2 Feb 2010 19:59:14 +0100
Subject: [PATCH] virStoragePoolSourceListNewSource: avoid unconditional leak

* src/conf/storage_conf.c (virStoragePoolSourceListNewSource):
Remove an unused (and leaked) allocation.
---
 src/conf/storage_conf.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index bd34f5e..62b8394 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1692,17 +1692,11 @@ virStoragePoolSourcePtr
 virStoragePoolSourceListNewSource(virConnectPtr conn,
                                   virStoragePoolSourceListPtr list)
 {
     virStoragePoolSourcePtr source;

-    if (VIR_ALLOC(source) < 0) {
-        virReportOOMError(conn);
-        return NULL;
-    }
-
     if (VIR_REALLOC_N(list->sources, list->nsources+1) < 0) {
-        VIR_FREE(source);
         virReportOOMError(conn);
         return NULL;
     }

     source = &list->sources[list->nsources++];
--
1.7.0.rc1.149.g0b0b7




More information about the libvir-list mailing list