summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2018-01-24 12:14:15 +0100
committerJunio C Hamano <gitster@pobox.com>2018-01-24 12:55:26 -0800
commit01caf20d57aea73e67337ba1d396dd80a76d9dc3 (patch)
tree2f9d0fbc1b5da3a128299efedcaaa12e30d28cb9 /commit.c
parentf34242975fae1468dd94d31289d27f68853a28fb (diff)
load_contents(): don't try to mmap an empty file
We don't actually create zero-length `packed-refs` files, but they are valid and we should handle them correctly. The old code `xmmap()`ed such files, which led to an error when `munmap()` was called. So, if the `packed-refs` file is empty, leave the snapshot at its zero values and return 0 without trying to read or mmap the file. Returning 0 also makes `create_snapshot()` exit early, which avoids the technically undefined comparison `NULL < NULL`. Reported-by: Kim Gybels <kgybels@infogroep.be> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
0 files changed, 0 insertions, 0 deletions