python: check return value of PyErr_NewException
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Thu, 23 Feb 2017 10:48:21 +0000 (11:48 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 23 Feb 2017 13:11:12 +0000 (13:11 +0000)
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/lowlevel/xs/xs.c

index 9e93d496f447394a706e98a3b28aec351ec053ad..6dcfb0a55602aecdf1c37db62b2db6ca9c775cb4 100644 (file)
@@ -2735,6 +2735,10 @@ PyMODINIT_FUNC initxc(void)
       return;
 
     xc_error_obj = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL);
+    if (xc_error_obj == NULL) {
+        Py_DECREF(m);
+        return;
+    }
     zero = PyInt_FromLong(0);
 
     /* KAF: This ensures that we get debug output in a timely manner. */
index a86edbe06f3370f71362f8c469d6d8e91041ce21..5772f4b1626493d5143b70da704cc8c0db991216 100644 (file)
@@ -987,6 +987,10 @@ PyMODINIT_FUNC initxs(void)
       return;
 
     xs_error = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL);
+    if (xs_error == NULL) {
+        Py_DECREF(m);
+        return;
+    }
 
     Py_INCREF(&xshandle_type);
     PyModule_AddObject(m, CLS, (PyObject *)&xshandle_type);