Skip to content

Commit ae9e6ef

Browse files
committed
Merge branch 'rs/git-mmap-uses-malloc' into maint
mmap() imitation used to call xmalloc() that dies upon malloc() failure, which has been corrected to just return an error to the caller to be handled. * rs/git-mmap-uses-malloc: compat: let git_mmap use malloc(3) directly
2 parents 3fb1d4d + 95b4ff3 commit ae9e6ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compat/mmap.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
77
if (start != NULL || flags != MAP_PRIVATE || prot != PROT_READ)
88
die("Invalid usage of mmap when built with NO_MMAP");
99

10-
start = xmalloc(length);
10+
if (length == 0) {
11+
errno = EINVAL;
12+
return MAP_FAILED;
13+
}
14+
15+
start = malloc(length);
1116
if (start == NULL) {
1217
errno = ENOMEM;
1318
return MAP_FAILED;

0 commit comments

Comments
 (0)