#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 8cf0e87..62d934c 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1388,6 +1388,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");