Commit 88ff684d authored by Junio C Hamano's avatar Junio C Hamano

diffcore-pickaxe: fix leaks in "log -S<block>" and "log -G<pattern>"

The diff_grep() and has_changes() functions had early return
codepaths for unmerged filepairs, which simply returned 0.  When we
taught textconv filter to them, one was ignored and continued to
return early without freeing the result filtered by textconv, and
the other had a failed attempt to fix, which allowed the planned
return value 0 to be overwritten by a bogus call to contains().
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent ebb72262
......@@ -99,7 +99,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
if (!DIFF_FILE_VALID(p->one)) {
if (!DIFF_FILE_VALID(p->two))
return 0; /* ignore unmerged */
hit = 0; /* ignore unmerged */
/* created "two" -- does it have what we are looking for? */
hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
} else if (!DIFF_FILE_VALID(p->two)) {
......@@ -229,6 +230,7 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,
if (!DIFF_FILE_VALID(p->one)) {
if (!DIFF_FILE_VALID(p->two))
ret = 0; /* ignore unmerged */
/* created */
ret = contains(&mf2, o, regexp, kws) != 0;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment