summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-08-16 03:08:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-08-18 17:15:19 (GMT)
commit735efde838b68747e737e863427a4843a8efaddb (patch)
tree4cef9ebadedd09e57441e0bcba740418e9ba5395 /sha1_file.c
parentf8bb1d94311b7438e7e9831b51ffb047b7ae65d7 (diff)
downloadgit-735efde838b68747e737e863427a4843a8efaddb.zip
git-735efde838b68747e737e863427a4843a8efaddb.tar.gz
git-735efde838b68747e737e863427a4843a8efaddb.tar.bz2
sha1_file.c: do not die failing to malloc in unpack_compressed_entry
Fewer die() gives better control to the caller, provided that the caller _can_ handle it. And in unpack_compressed_entry() case, it can, because unpack_compressed_entry() already returns NULL if it fails to inflate data. A side effect from this is fsck continues to run when very large blobs are present (and do not fit in memory). Noticed-by: Dale R. Worley <worley@alum.mit.edu> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 3f70b1d..8db73f0 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1923,7 +1923,9 @@ static void *unpack_compressed_entry(struct packed_git *p,
git_zstream stream;
unsigned char *buffer, *in;
- buffer = xmallocz(size);
+ buffer = xmallocz_gently(size);
+ if (!buffer)
+ return NULL;
memset(&stream, 0, sizeof(stream));
stream.next_out = buffer;
stream.avail_out = size + 1;