Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-09-08 23:30:27 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-08 23:30:27 +0300
commitce7ae09bd4912fbd54b01089f2dfe01a94cb7fea (patch)
tree3c60e78fe617bb32d4c3376a038a7935cfdd2016 /compat
parente18f4de927c024eb459912f21b7906d409e0e95f (diff)
parent95b4ff3931064ff222e87eecf6af504ba55069d7 (diff)
Merge branch 'rs/git-mmap-uses-malloc'
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
Diffstat (limited to 'compat')
-rw-r--r--compat/mmap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/compat/mmap.c b/compat/mmap.c
index 14d31010df..8d6c02d4bc 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -7,7 +7,12 @@ 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 (length == 0) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ start = malloc(length);
if (start == NULL) {
errno = ENOMEM;
return MAP_FAILED;