]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport trunk's r42890 (thomas.wouters):
authorThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 14:16:02 +0000 (14:16 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 7 Mar 2006 14:16:02 +0000 (14:16 +0000)
Coverity found bug: test result of PyTuple_New() against NULL before use.

and r42891 (thomas.wouters):

Fix gcc 4.0.x warning about use of uninitialized value.

Modules/_bsddb.c

index 07c56cdd66b26196d4ce2a9bab7270844eda7bcd..de072b07af7985c1253a6054e200f30b23b1bdb1 100644 (file)
@@ -1063,7 +1063,7 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
     PyObject* key;
     PyObject* data;
     PyObject* args;
-    PyObject* result;
+    PyObject* result = NULL;
 
 
     if (callback != NULL) {
@@ -1077,12 +1077,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) {