summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2001-07-16 15:47:36 (GMT)
committerThomas Wouters <thomas@python.org>2001-07-16 15:47:36 (GMT)
commit1baac7201e99cb83f0a153fb3764c8c8daa9414d (patch)
tree0a927e45e69b02d6d4d1ea487b88e0a00191c184 /Modules
parent687a17deaacdde85b7a9f33d36cc1eea9c868039 (diff)
downloadcpython-1baac7201e99cb83f0a153fb3764c8c8daa9414d.zip
cpython-1baac7201e99cb83f0a153fb3764c8c8daa9414d.tar.gz
cpython-1baac7201e99cb83f0a153fb3764c8c8daa9414d.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 63ef72a..d5bc89f 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -663,6 +663,11 @@ mmap_ass_slice(mmap_object *self, int ilow, int ihigh, PyObject *v)
else if ((size_t)ihigh > self->size)
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,
"mmap slice assignment must be a string");
@@ -688,6 +693,11 @@ mmap_ass_item(mmap_object *self, int i, PyObject *v)
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;
+ }
if (! (PyString_Check(v) && PyString_Size(v)==1) ) {
PyErr_SetString(PyExc_IndexError,
"mmap assignment must be single-character string");