python: Improve error handling.
authorJustus Winter <justus@g10code.com>
Wed, 14 Sep 2016 12:34:14 +0000 (14:34 +0200)
committerJustus Winter <justus@g10code.com>
Wed, 14 Sep 2016 12:34:14 +0000 (14:34 +0200)
* lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
lang/python/gpgme.i

index bc957e5..458ae7f 100644 (file)
     size++;
   }
   $result = PyList_New(size);
+  if ($result == NULL)
+    return NULL;       /* raise */
   for (i=0,curr=$1; i<size; i++,curr=curr->next) {
     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);
   }
 }