]> git.ipfire.org Git - thirdparty/git.git/commitdiff
shallow.c: don't free unallocated slabs
authorAli Utku Selen <auselen@gmail.com>
Mon, 30 Sep 2019 23:33:10 +0000 (01:33 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Oct 2019 06:03:47 +0000 (15:03 +0900)
Fix possible segfault when cloning a submodule shallow.

Signed-off-by: Ali Utku Selen <auselen@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
shallow.c

index c1b68533ca3d831afcef7fd655cce95d8db89547..8de0bad2a5afd6547c56bed5bf6a1179ba574423 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -148,6 +148,8 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
        for (i = 0; i < depths.slab_count; i++) {
                int j;
 
+               if (!depths.slab[i])
+                       continue;
                for (j = 0; j < depths.slab_size; j++)
                        free(depths.slab[i][j]);
        }