[Python-checkins] CVS: python/dist/src/Modules gdbmmodule.c,2.19,2.20

Fred L. Drake fdrake@weyr.cnri.reston.va.us
Mon, 7 Feb 2000 12:19:44 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Modules
In directory weyr:/home/fdrake/projects/python/Modules

Modified Files:
	gdbmmodule.c 
Log Message:

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>.


Index: gdbmmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/gdbmmodule.c,v
retrieving revision 2.19
retrieving revision 2.20
diff -C2 -r2.19 -r2.20
*** gdbmmodule.c	1998/12/04 18:49:49	2.19
--- gdbmmodule.c	2000/02/07 17:19:41	2.20
***************
*** 156,160 ****
  	if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize) )
  		return NULL;
! 	
  	drec = gdbm_fetch(dp->di_dbm, krec);
  	if ( drec.dptr == 0 ) {
--- 156,165 ----
  	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 ) {
***************
*** 181,185 ****
  	}
          if (dp->di_dbm == NULL) {
!                  PyErr_SetString(DbmError, "GDBM object has already been closed"); 
                   return -1; 
          }
--- 186,191 ----
  	}
          if (dp->di_dbm == NULL) {
!                  PyErr_SetString(DbmError,
!                                  "GDBM object has already been closed"); 
                   return -1; 
          }