Merged revisions 78563 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78563 | florent.xicluna | 2010-03-01 21:45:01 +0100 (lun, 01 mar 2010) | 2 lines

  #7808: Fix reference leaks in _bsddb and related tests.
........
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 149e43d..5aedfca 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -2382,8 +2382,6 @@
 
 	args = BuildValue_SS(leftKey->data, leftKey->size, rightKey->data, rightKey->size);
 	if (args != NULL) {
-		/* XXX(twouters) I highly doubt this INCREF is correct */
-		Py_INCREF(self);
 		result = PyEval_CallObject(self->btCompareCallback, args);
 	}
 	if (args == NULL || result == NULL) {
@@ -2432,10 +2430,12 @@
     if (result == NULL)
         return NULL;
     if (!NUMBER_Check(result)) {
+	Py_DECREF(result);
 	PyErr_SetString(PyExc_TypeError,
 		        "callback MUST return an int");
 	return NULL;
     } else if (NUMBER_AsLong(result) != 0) {
+	Py_DECREF(result);
 	PyErr_SetString(PyExc_TypeError,
 		        "callback failed to return 0 on two empty strings");
 	return NULL;
@@ -5776,6 +5776,8 @@
             free(listp);
             return NULL;
         }
+        Py_DECREF(key);
+        Py_DECREF(tuple);
     }
     free(listp);
     return stats;
@@ -7578,4 +7580,3 @@
     return PyInit__bsddb();   /* Note the two underscores */
 #endif
 }
-