]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libvirt-override.c: avoid a leak upon call with invalid argument
authorJim Meyering <meyering@redhat.com>
Tue, 16 Feb 2010 07:07:38 +0000 (08:07 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 16 Feb 2010 16:49:05 +0000 (17:49 +0100)
* python/libvirt-override.c (libvirt_virConnectBaselineCPU): Don't leak
the xmlcpus buffer upon encountering a non-string list element.

python/libvirt-override.c

index a71766a59321330cc0faebb531cdc25f61c407f1..2447ad7052dce38f6c3ced3fa48a4afc2b1eb794 100644 (file)
@@ -4,7 +4,7 @@
  *           entry points where an automatically generated stub is
  *           unpractical
  *
- * Copyright (C) 2005, 2007-2009 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2010 Red Hat, Inc.
  *
  * Daniel Veillard <veillard@redhat.com>
  */
@@ -2046,8 +2046,10 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
 
         for (i = 0; i < ncpus; i++) {
             xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
-            if (xmlcpus[i] == NULL)
+            if (xmlcpus[i] == NULL) {
+                free(xmlcpus);
                 return VIR_PY_INT_FAIL;
+            }
         }
     }