From 44d18200d5ffe8691e18d93ce6c534660702b982 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 14 Sep 2016 14:34:14 +0200 Subject: [PATCH] python: Improve error handling. * lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling. Signed-off-by: Justus Winter --- lang/python/gpgme.i | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i index bc957e57..458ae7f1 100644 --- a/lang/python/gpgme.i +++ b/lang/python/gpgme.i @@ -452,14 +452,24 @@ size++; } $result = PyList_New(size); + if ($result == NULL) + return NULL; /* raise */ for (i=0,curr=$1; inext) { PyObject *fragile, *o; fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor, %newpointer_flags); + if (fragile == NULL) + { + Py_DECREF($result); + return NULL; /* raise */ + } o = _pyme_wrap_result(fragile, "EngineInfo"); - if (o == NULL) - return NULL; /* raise */ Py_DECREF(fragile); + if (o == NULL) + { + Py_DECREF($result); + return NULL; /* raise */ + } PyList_SetItem($result, i, o); } }