diff --git a/glib/gmappedfile.c b/glib/gmappedfile.c index c8e513b76..222e05703 100644 --- a/glib/gmappedfile.c +++ b/glib/gmappedfile.c @@ -155,6 +155,13 @@ mapped_file_new_from_fd (int fd, file->contents = NULL; return file; } + else if (st.st_size == 0) + { + errno = EINVAL; + file->length = 0; + file->contents = MAP_FAILED; + goto error; + } file->contents = MAP_FAILED; @@ -192,7 +199,7 @@ mapped_file_new_from_fd (int fd, } #endif - +error: if (file->contents == MAP_FAILED) { if (error != NULL)