@matheusbsbs / matheus-bagliano / commits / d64d6c9fc7
Fork 0

get_shallow_commits: Avoid memory leak if a commit has been reached already.

Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Alexandre Julliard committed Nov 24, 2006 at 15:58 UTC d64d6c9fc712cf6fad9a3ec7f659cf843ee2e18d
1 file changed +3 -1
shallow.c
+3 -1
@@ -60,7 +60,9 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
60 commit = NULL;
61 continue;
62 }
63 - commit->util = xcalloc(1, sizeof(int));
63 + if (!commit->util)
64 + commit->util = xmalloc(sizeof(int));
65 + *(int *)commit->util = 0;
66 cur_depth = 0;
67 } else {
68 commit = (struct commit *)