python: Improve error handling.

* lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-09-14 14:34:14 +02:00
parent f6cd560ca7
commit 44d18200d5

View File

@ -452,14 +452,24 @@
size++; size++;
} }
$result = PyList_New(size); $result = PyList_New(size);
if ($result == NULL)
return NULL; /* raise */
for (i=0,curr=$1; i<size; i++,curr=curr->next) { for (i=0,curr=$1; i<size; i++,curr=curr->next) {
PyObject *fragile, *o; PyObject *fragile, *o;
fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor, fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
%newpointer_flags); %newpointer_flags);
o = _pyme_wrap_result(fragile, "EngineInfo"); if (fragile == NULL)
if (o == NULL) {
Py_DECREF($result);
return NULL; /* raise */ return NULL; /* raise */
}
o = _pyme_wrap_result(fragile, "EngineInfo");
Py_DECREF(fragile); Py_DECREF(fragile);
if (o == NULL)
{
Py_DECREF($result);
return NULL; /* raise */
}
PyList_SetItem($result, i, o); PyList_SetItem($result, i, o);
} }
} }