]> granicus.if.org Git - python/commitdiff
Coverity found bug: test result of PyTuple_New() against NULL before use.
authorThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 14:13:17 +0000 (14:13 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 14:13:17 +0000 (14:13 +0000)
Will backport.

Modules/_bsddb.c

index 8f8eab24c3489f0e506890fdda5962a8455cc48d..f938ff044cbb64cd5c73a8b38f53a0cfd5d722a6 100644 (file)
@@ -1084,12 +1084,12 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
         }
         data = PyString_FromStringAndSize(priData->data, priData->size);
         args = PyTuple_New(2);
-        PyTuple_SET_ITEM(args, 0, key);  /* steals reference */
-        PyTuple_SET_ITEM(args, 1, data); /* steals reference */
-
-        result = PyEval_CallObject(callback, args);
-
-        if (result == NULL) {
+        if (args != NULL) {
+                PyTuple_SET_ITEM(args, 0, key);  /* steals reference */
+                PyTuple_SET_ITEM(args, 1, data); /* steals reference */
+                result = PyEval_CallObject(callback, args);
+        }
+        if (args == NULL || result == NULL) {
             PyErr_Print();
         }
         else if (result == Py_None) {