summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-02-07 17:19:41 (GMT)
committerFred Drake <fdrake@acm.org>2000-02-07 17:19:41 (GMT)
commitda8d216eb2abc65e0628ac59e300ccc331338151 (patch)
tree60bd296b5ebf350b6b52936a1b6f952012968e0b /Modules
parenta710d6e20cebc0d8a2aa6e8df5c37d9263d86d9b (diff)
downloadcpython-da8d216eb2abc65e0628ac59e300ccc331338151.zip
cpython-da8d216eb2abc65e0628ac59e300ccc331338151.tar.gz
cpython-da8d216eb2abc65e0628ac59e300ccc331338151.tar.bz2
Protect against core dumps in gdbm: don't allow access by key once the
database is closed. Raise gdbm.error instead. Bug report #198 submitted by Barry Haddow <bhaddow@orbism.com>.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gdbmmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c
index 0df7df2..31855f5 100644
--- a/Modules/gdbmmodule.c
+++ b/Modules/gdbmmodule.c
@@ -155,7 +155,12 @@ register PyObject *key;
if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize) )
return NULL;
-
+
+ if (dp->di_dbm == NULL) {
+ PyErr_SetString(DbmError,
+ "GDBM object has already been closed");
+ return NULL;
+ }
drec = gdbm_fetch(dp->di_dbm, krec);
if ( drec.dptr == 0 ) {
PyErr_SetString(PyExc_KeyError,
@@ -180,7 +185,8 @@ PyObject *v, *w;
return -1;
}
if (dp->di_dbm == NULL) {
- PyErr_SetString(DbmError, "GDBM object has already been closed");
+ PyErr_SetString(DbmError,
+ "GDBM object has already been closed");
return -1;
}
dp->di_size = -1;