summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r--main/streams/plain_wrapper.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 50ca925dea..298950cf9e 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -826,6 +826,11 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
delta = (DWORD)range->offset - loffs;
}
+ /* MapViewOfFile()ing zero bytes would map to the end of the file; match *nix behavior instead */
+ if (range->length + delta == 0) {
+ return PHP_STREAM_OPTION_RETURN_ERR;
+ }
+
data->last_mapped_addr = MapViewOfFile(data->file_mapping, acc, 0, loffs, range->length + delta);
if (data->last_mapped_addr) {