From: Junio C Hamano Date: Mon, 29 May 2017 03:34:44 +0000 (+0900) Subject: Merge branch 'js/plug-leaks' X-Git-Tag: v2.14.0-rc0~164 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=849e671b52e11d4a2f70d577dd2c806f3ca756fe;p=thirdparty%2Fgit.git Merge branch 'js/plug-leaks' Fix memory leaks pointed out by Coverity (and people). * js/plug-leaks: (26 commits) checkout: fix memory leak submodule_uses_worktrees(): plug memory leak show_worktree(): plug memory leak name-rev: avoid leaking memory in the `deref` case remote: plug memory leak in match_explicit() add_reflog_for_walk: avoid memory leak shallow: avoid memory leak line-log: avoid memory leak receive-pack: plug memory leak in update() fast-export: avoid leaking memory in handle_tag() mktree: plug memory leaks reported by Coverity pack-redundant: plug memory leak setup_discovered_git_dir(): plug memory leak setup_bare_git_dir(): help static analysis split_commit_in_progress(): simplify & fix memory leak checkout: fix memory leak cat-file: fix memory leak mailinfo & mailsplit: check for EOF while parsing status: close file descriptor after reading git-rebase-todo difftool: address a couple of resource/memory leaks ... --- 849e671b52e11d4a2f70d577dd2c806f3ca756fe diff --cc shallow.c index 6950cc24f0,f9370961f9..ef7ca78993 --- a/shallow.c +++ b/shallow.c @@@ -473,11 -473,15 +473,15 @@@ static void paint_down(struct paint_inf struct commit_list *head = NULL; int bitmap_nr = (info->nr_bits + 31) / 32; size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr); - uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */ - uint32_t *bitmap = paint_alloc(info); - struct commit *c = lookup_commit_reference_gently(sha1, 1); + struct commit *c = lookup_commit_reference_gently(oid, 1); + uint32_t *tmp; /* to be freed before return */ + uint32_t *bitmap; + if (!c) return; + + tmp = xmalloc(bitmap_size); + bitmap = paint_alloc(info); memset(bitmap, 0, bitmap_size); bitmap[id / 32] |= (1U << (id % 32)); commit_list_insert(c, &head);