path: root/commit.c
diff options
authorEric Wong <>2005-12-24 12:12:43 (GMT)
committerJunio C Hamano <>2005-12-26 16:59:21 (GMT)
commit7d6fb370bc98e5d4723103dda0829b00c79da213 (patch)
treea2b3b32b5e0e2e43fbff7cd2bf6c6e60e78cbecd /commit.c
parentac44f3e7c05390531004d567481004c96d1b262c (diff)
short circuit out of a few places where we would allocate zero bytes
dietlibc versions of malloc, calloc and realloc all return NULL if they're told to allocate 0 bytes, causes the x* wrappers to die(). There are several more places where these calls could end up asking for 0 bytes, too... Maybe simply not die()-ing in the x* wrappers if 0/NULL is returned when the requested size is zero is a safer and easier way to go. Signed-off-by: Eric Wong <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 3 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index e867b86..edd4ded 100644
--- a/commit.c
+++ b/commit.c
@@ -560,6 +560,9 @@ void sort_in_topological_order(struct commit_list ** list)
next = next->next;
+ if (!count)
+ return;
/* allocate an array to help sort the list */
nodes = xcalloc(count, sizeof(*nodes));
/* link the list to the array */