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>
This commit is contained in:
Ali Utku Selen 2019-10-01 01:33:10 +02:00 committed by Junio C Hamano
parent 98cdfbb84a
commit ddb3c856f3

View file

@ -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]);
}