]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix memory leak in OOM cleanup
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 7 Jul 2008 09:52:26 +0000 (09:52 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 7 Jul 2008 09:52:26 +0000 (09:52 +0000)
ChangeLog
src/capabilities.c

index de6ed7887de8d65787e4575f6a2a5906546df337..5b999b58a9d8b17aa9731d91d4b415bfc47ae7ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jul  7 10:39:56 BST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/capabilities.c: Refactor to avoid memory leak when in
+       cleanup from OOM condition
+
 Mon Jun 30 14:07:56 JST 2008 Atsushi SAKAI <sakaia@jp.fujitsu.com>
 
        Compilation fix for MinGW
index 86ee4d3a03e39ecf3ad3c29466168551b1056a30..2b7576e807fd8570dc0bc356b6cf930d51eb28aa 100644 (file)
@@ -224,17 +224,19 @@ virCapabilitiesAddHostNUMACell(virCapsPtr caps,
 
     if (VIR_ALLOC(cell) < 0)
         return -1;
-    caps->host.numaCell[caps->host.nnumaCell] = cell;
 
-    if (VIR_ALLOC_N(caps->host.numaCell[caps->host.nnumaCell]->cpus,
-                    ncpus) < 0)
+    if (VIR_ALLOC_N(cell->cpus, ncpus) < 0) {
+        VIR_FREE(cell);
         return -1;
-    memcpy(caps->host.numaCell[caps->host.nnumaCell]->cpus,
+    }
+    memcpy(cell->cpus,
            cpus,
            ncpus * sizeof(*cpus));
 
-    caps->host.numaCell[caps->host.nnumaCell]->ncpus = ncpus;
-    caps->host.numaCell[caps->host.nnumaCell]->num = num;
+    cell->ncpus = ncpus;
+    cell->num = num;
+
+    caps->host.numaCell[caps->host.nnumaCell] = cell;
     caps->host.nnumaCell++;
 
     return 0;