summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2006-06-05 00:33:35 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2006-06-05 00:33:35 (GMT)
commitbad474544c777ba15c474374c4ee1ef5288fdebf (patch)
treeb3142d2775b83abe592730a00f935875f93512ad
parent3dd20022ac3da63c4fe867a773d623e4fa1fce04 (diff)
downloadcpython-bad474544c777ba15c474374c4ee1ef5288fdebf.zip
cpython-bad474544c777ba15c474374c4ee1ef5288fdebf.tar.gz
cpython-bad474544c777ba15c474374c4ee1ef5288fdebf.tar.bz2
fix a bug in the previous commit. don't leak empty list on error return and
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.
-rw-r--r--Modules/_bsddb.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 2df73fe..aad4d1f 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -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) {