summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-09-10 20:45:47 (GMT)
committerJesus Cea <jcea@jcea.es>2012-09-10 20:45:47 (GMT)
commit20f0ea1f610842c98bbfcf653f4414b88f767083 (patch)
tree8296a1be6e25c682069ab19f52f5bfcfc9b2f70f /Modules
parent3fb774ec5f64f0856767e5726d8083a5bf63f33e (diff)
downloadcpython-20f0ea1f610842c98bbfcf653f4414b88f767083.zip
cpython-20f0ea1f610842c98bbfcf653f4414b88f767083.tar.gz
cpython-20f0ea1f610842c98bbfcf653f4414b88f767083.tar.bz2
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 8cf0e87..62d934c 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1388,6 +1388,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
}
size = (((PY_LONG_LONG) high) << 32) + low;
+ if (size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "cannot mmap an empty file");
+ return NULL;
+ }
if (offset >= size) {
PyErr_SetString(PyExc_ValueError,
"mmap offset is greater than file size");