#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index e23613e..b993fdf 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1342,6 +1342,11 @@
}
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");