[Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.31,2.32

Thomas Wouters twouters@users.sourceforge.net
Mon, 16 Jul 2001 08:47:38 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv24334

Modified Files:
	mmapmodule.c 
Log Message:

Fix SF #441664: Python crash on del of a slice of a mmap

Check for slice/item deletion, which calls slice/item assignment with a NULL
value, and raise a TypeError instead of coredumping. Bugreport and suggested
fix by Alex Martelli.



Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.31
retrieving revision 2.32
diff -C2 -r2.31 -r2.32
*** mmapmodule.c	2001/05/14 23:19:12	2.31
--- mmapmodule.c	2001/07/16 15:47:36	2.32
***************
*** 664,667 ****
--- 664,672 ----
  		ihigh = self->size;
      
+ 	if (v == NULL) {
+ 		PyErr_SetString(PyExc_TypeError,
+ 			"mmap object doesn't support slice deletion");
+ 		return -1;
+ 	}
  	if (! (PyString_Check(v)) ) {
  		PyErr_SetString(PyExc_IndexError, 
***************
*** 687,690 ****
--- 692,700 ----
  	if (i < 0 || (size_t)i >= self->size) {
  		PyErr_SetString(PyExc_IndexError, "mmap index out of range");
+ 		return -1;
+ 	}
+ 	if (v == NULL) {
+ 		PyErr_SetString(PyExc_TypeError,
+ 			"mmap object doesn't support item deletion");
  		return -1;
  	}