Skip to content

Commit 14dd698

Browse files
dschoGit for Windows Build Agent
authored andcommitted
shallow: avoid memory leak
Reported by Coverity. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d1b3bf6 commit 14dd698

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

shallow.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,15 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
473473
struct commit_list *head = NULL;
474474
int bitmap_nr = (info->nr_bits + 31) / 32;
475475
size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
476-
uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */
477-
uint32_t *bitmap = paint_alloc(info);
478476
struct commit *c = lookup_commit_reference_gently(sha1, 1);
477+
uint32_t *tmp; /* to be freed before return */
478+
uint32_t *bitmap;
479+
479480
if (!c)
480481
return;
482+
483+
tmp = xmalloc(bitmap_size);
484+
bitmap = paint_alloc(info);
481485
memset(bitmap, 0, bitmap_size);
482486
bitmap[id / 32] |= (1U << (id % 32));
483487
commit_list_insert(c, &head);

0 commit comments

Comments
 (0)