shallow.c: don't free unallocated slabs

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>

Ali Utku Selen committed Oct 1, 2019 at 01:33 UTC ddb3c856f32fe291b52544e177d2246c09cadd2c
1 file changed +2
shallow.c
+2
@@ -148,6 +148,8 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
148 for (i = 0; i < depths.slab_count; i++) {
149 int j;
150
151 + if (!depths.slab[i])
152 + continue;
153 for (j = 0; j < depths.slab_size; j++)
154 free(depths.slab[i][j]);
155 }