[Libguestfs] [PATCH 3/7] python: Stop using the safe_malloc, etc. functions.

Richard W.M. Jones rjones at redhat.com
Fri Feb 5 14:21:37 UTC 2016


---
 python/guestfs-py-byhand.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c
index 6d3e71d..b200dc6 100644
--- a/python/guestfs-py-byhand.c
+++ b/python/guestfs-py-byhand.c
@@ -75,6 +75,8 @@ guestfs_int_py_close (PyObject *self, PyObject *args)
    * in a double-free here.  XXX
    */
   callbacks = get_all_event_callbacks (g, &len);
+  if (callbacks == NULL)
+    return NULL;
 
   if (PyEval_ThreadsInitialized ())
     py_save = PyEval_SaveThread ();
@@ -251,7 +253,11 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
   }
 
   /* Copy them into the return array. */
-  r = guestfs_int_safe_malloc (g, sizeof (PyObject *) * (*len_rtn));
+  r = malloc (sizeof (PyObject *) * (*len_rtn));
+  if (r == NULL) {
+    PyErr_SetNone (PyExc_MemoryError);
+    return NULL;
+  }
 
   i = 0;
   cb = guestfs_first_private (g, &key);
-- 
2.5.0




More information about the Libguestfs mailing list