libvirt-override.c: avoid a leak upon call with invalid argument

* python/libvirt-override.c (libvirt_virConnectBaselineCPU): Don't leak
the xmlcpus buffer upon encountering a non-string list element.
This commit is contained in:
Jim Meyering 2010-02-16 08:07:38 +01:00
parent dc03ae2c6d
commit f89c67cf19

View File

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