summaryrefslogtreecommitdiff
path: root/compat/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'compat/mmap.c')
-rw-r--r--compat/mmap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/compat/mmap.c b/compat/mmap.c
index 14d3101..2fe1c77 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -7,8 +7,13 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
if (start != NULL || flags != MAP_PRIVATE || prot != PROT_READ)
die("Invalid usage of mmap when built with NO_MMAP");
- start = xmalloc(length);
- if (start == NULL) {
+ if (length == 0) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ start = malloc(length);
+ if (!start) {
errno = ENOMEM;
return MAP_FAILED;
}