summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2011-05-23 14:41:00 +0200
committerMichal Privoznik <mprivozn@redhat.com>2011-05-24 10:33:36 +0200
commitebf5ee12d15857363bcfde7fed25aa7fe8334d79 (patch)
tree1430916de3c92d87b2cf78e056b4c5857673d044
parent080c8ac14aecdba2b125eddd94d75c2f95ecf831 (diff)
downloadlibvirt-python-split-ebf5ee12d15857363bcfde7fed25aa7fe8334d79.tar.gz
libvirt-python-split-ebf5ee12d15857363bcfde7fed25aa7fe8334d79.tar.xz
libvirt-python-split-ebf5ee12d15857363bcfde7fed25aa7fe8334d79.zip
python: Don't free must-not-free variables
py_str() function call PyString_AsString(). As written in documentation, the caller must not free the returned value, because it points to some internal structures.
-rw-r--r--libvirt-override.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/libvirt-override.c b/libvirt-override.c
index a151e78..c42931d 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -35,6 +35,9 @@ extern void initcygvirtmod(void);
#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
+/* We don't want to free() returned value. As written in doc:
+ * PyString_AsString returns pointer to 'internal buffer of string,
+ * not a copy' and 'It must not be deallocated'. */
static char *py_str(PyObject *obj)
{
PyObject *str = PyObject_Str(obj);
@@ -2660,7 +2663,6 @@ libvirt_virEventAddHandleFunc (int fd,
char *name = py_str(python_cb);
printf("%s: %s is not callable\n", __FUNCTION__,
name ? name : "libvirt.eventInvokeHandleCallback");
- free(name);
#endif
goto cleanup;
}
@@ -2805,7 +2807,6 @@ libvirt_virEventAddTimeoutFunc(int timeout,
char *name = py_str(python_cb);
printf("%s: %s is not callable\n", __FUNCTION__,
name ? name : "libvirt.eventInvokeTimeoutCallback");
- free(name);
#endif
goto cleanup;
}
@@ -2919,17 +2920,11 @@ libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject * self,
{
/* Unref the previously-registered impl (if any) */
Py_XDECREF(addHandleObj);
- free(addHandleName);
Py_XDECREF(updateHandleObj);
- free(updateHandleName);
Py_XDECREF(removeHandleObj);
- free(removeHandleName);
Py_XDECREF(addTimeoutObj);
- free(addTimeoutName);
Py_XDECREF(updateTimeoutObj);
- free(updateTimeoutName);
Py_XDECREF(removeTimeoutObj);
- free(removeTimeoutName);
/* Parse and check arguments */
if (!PyArg_ParseTuple(args, (char *) "OOOOOO:virEventRegisterImpl",