[Python-checkins] r42892 - python/branches/release24-maint/Modules/_bsddb.c

thomas.wouters python-checkins at python.org
Tue Mar 7 15:16:03 CET 2006


Author: thomas.wouters
Date: Tue Mar  7 15:16:02 2006
New Revision: 42892

Modified:
   python/branches/release24-maint/Modules/_bsddb.c
Log:

Backport trunk's r42890 (thomas.wouters):

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.



Modified: python/branches/release24-maint/Modules/_bsddb.c
==============================================================================
--- python/branches/release24-maint/Modules/_bsddb.c	(original)
+++ python/branches/release24-maint/Modules/_bsddb.c	Tue Mar  7 15:16:02 2006
@@ -1063,7 +1063,7 @@
     PyObject* key;
     PyObject* data;
     PyObject* args;
-    PyObject* result;
+    PyObject* result = NULL;
 
 
     if (callback != NULL) {
@@ -1077,12 +1077,12 @@
         }
         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) {


More information about the Python-checkins mailing list