mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-04 18:18:56 +01:00
gmappedfile: Avoid calling mmap() with a length of zero
We were previously relying on it returning `EINVAL` so we could return an error message, but scan-build doesn’t like that, so let’s just explicitly return the same error anyway to shut scan-build up. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -155,6 +155,13 @@ mapped_file_new_from_fd (int fd,
|
|||||||
file->contents = NULL;
|
file->contents = NULL;
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
else if (st.st_size == 0)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
file->length = 0;
|
||||||
|
file->contents = MAP_FAILED;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
file->contents = MAP_FAILED;
|
file->contents = MAP_FAILED;
|
||||||
|
|
||||||
@@ -192,7 +199,7 @@ mapped_file_new_from_fd (int fd,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
error:
|
||||||
if (file->contents == MAP_FAILED)
|
if (file->contents == MAP_FAILED)
|
||||||
{
|
{
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user