]> granicus.if.org Git - python/commitdiff
fix a bug in the previous commit. don't leak empty list on error return and
authorGregory P. Smith <greg@mad-scientist.com>
Mon, 5 Jun 2006 00:33:35 +0000 (00:33 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Mon, 5 Jun 2006 00:33:35 +0000 (00:33 +0000)
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.

Modules/_bsddb.c

index 2df73febc2df8887ff58b2f850a1648bf8122600..aad4d1f3bdf7c7641613bcd04990637f5455c99a 100644 (file)
@@ -4378,10 +4378,6 @@ DBEnv_log_archive(DBEnvObject* self, PyObject* args)
     if (!PyArg_ParseTuple(args, "|i:log_archive", &flags))
         return NULL;
 
-    list = PyList_New(0);
-    if (list == NULL)
-        return NULL;
-
     CHECK_ENV_NOT_CLOSED(self);
     MYDB_BEGIN_ALLOW_THREADS;
 #if (DBVER >= 40)
@@ -4394,6 +4390,13 @@ DBEnv_log_archive(DBEnvObject* self, PyObject* args)
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
+    list = PyList_New(0);
+    if (list == NULL) {
+        if (log_list)
+            free(log_list);
+        return NULL;
+    }
+
     if (log_list) {
         char **log_list_start;
         for (log_list_start = log_list; *log_list != NULL; ++log_list) {