summaryrefslogtreecommitdiffstats
path: root/Modules/gdbmmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-08-28 02:58:00 (GMT)
committerGuido van Rossum <guido@python.org>1995-08-28 02:58:00 (GMT)
commit66017aa1b8af3983b882f196ac39b3abf3603bbb (patch)
tree9aab91a724ab541bee7d5342caee0abcc265cf20 /Modules/gdbmmodule.c
parent05870115fce58aa78262cc46102f7e0106ff5779 (diff)
downloadcpython-66017aa1b8af3983b882f196ac39b3abf3603bbb.zip
cpython-66017aa1b8af3983b882f196ac39b3abf3603bbb.tar.gz
cpython-66017aa1b8af3983b882f196ac39b3abf3603bbb.tar.bz2
fix leaks in keys(); fix bug in close()
Diffstat (limited to 'Modules/gdbmmodule.c')
-rw-r--r--Modules/gdbmmodule.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c
index 021531c..e5bc4ac 100644
--- a/Modules/gdbmmodule.c
+++ b/Modules/gdbmmodule.c
@@ -177,7 +177,6 @@ dbm_close(dp, args)
if ( dp->di_dbm )
gdbm_close(dp->di_dbm);
dp->di_dbm = NULL;
- DEL(dp);
INCREF(None);
return None;
}
@@ -189,6 +188,7 @@ dbm_keys(dp, args)
{
register object *v, *item;
datum key, okey={ (char *)NULL, 0};
+ int err;
if (dp == NULL || !is_dbmobject(dp)) {
err_badcall();
@@ -202,10 +202,17 @@ dbm_keys(dp, args)
for (key = gdbm_firstkey(dp->di_dbm); key.dptr;
key = gdbm_nextkey(dp->di_dbm,okey) ) {
item = newsizedstringobject(key.dptr, key.dsize);
- if ( item == 0 )
- return NULL;
- addlistitem(v, item);
+ if (item == 0) {
+ DECREF(v);
+ return NULL;
+ }
+ err = addlistitem(v, item);
+ DECREF(item);
if(okey.dsize) free(okey.dptr);
+ if (err != 0) {
+ DECREF(v);
+ return NULL;
+ }
okey=key;
}
return v;