From 6b28df34b5681197154e26be05c9faacbbcf5d55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 23 Feb 2017 11:48:21 +0100 Subject: [PATCH] python: check return value of PyErr_NewException MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Marczykowski-Górecki Acked-by: Wei Liu --- tools/python/xen/lowlevel/xc/xc.c | 4 ++++ tools/python/xen/lowlevel/xs/xs.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 9e93d496f4..6dcfb0a556 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -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. */ diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index a86edbe06f..5772f4b162 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -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); -- 2.30.2