From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/3] diffcore-pickaxe: fix leaks in "log -S<block>" and "log -G<pattern>"
Date: Thu, 4 Apr 2013 21:45:25 -0700 [thread overview]
Message-ID: <1365137126-21659-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1365137126-21659-1-git-send-email-gitster@pobox.com>
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: Junio C Hamano <gitster@pobox.com>
---
diffcore-pickaxe.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index bfaabab..cadb071 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -99,9 +99,10 @@ 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 */
- /* created "two" -- does it have what we are looking for? */
- hit = !regexec(regexp, mf2.ptr, 1, ®match, 0);
+ hit = 0; /* ignore unmerged */
+ else
+ /* created "two" -- does it have what we are looking for? */
+ hit = !regexec(regexp, mf2.ptr, 1, ®match, 0);
} else if (!DIFF_FILE_VALID(p->two)) {
/* removed "one" -- did it have what we are looking for? */
hit = !regexec(regexp, mf1.ptr, 1, ®match, 0);
@@ -229,8 +230,9 @@ 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;
+ else
+ /* created */
+ ret = contains(&mf2, o, regexp, kws) != 0;
}
else if (!DIFF_FILE_VALID(p->two)) /* removed */
ret = contains(&mf1, o, regexp, kws) != 0;
--
1.8.2-588-gbf1c992
next prev parent reply other threads:[~2013-04-05 4:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-04 8:34 [BUG] git log -S not respecting --no-textconv Matthieu Moy
2013-04-04 16:03 ` [PATCH 1/2] diffcore-pickaxe: respect --no-textconv Simon Ruderich
2013-04-04 17:03 ` Matthieu Moy
2013-04-04 17:43 ` Jeff King
2013-04-04 17:45 ` Junio C Hamano
2013-04-04 17:51 ` Jeff King
2013-04-04 18:10 ` Junio C Hamano
2013-04-04 20:20 ` [PATCH v2 1/3] diffcore-pickaxe: remove unnecessary call to get_textconv() Simon Ruderich
2013-04-04 20:48 ` Junio C Hamano
2013-04-04 21:10 ` Junio C Hamano
2013-04-04 21:11 ` Jeff King
2013-04-04 22:51 ` Junio C Hamano
2013-04-05 13:20 ` Simon Ruderich
2013-04-04 20:21 ` [PATCH v2 2/3] diffcore-pickaxe: remove fill_one() Simon Ruderich
2013-04-05 0:08 ` Jeff King
2013-04-05 4:43 ` Junio C Hamano
2013-04-05 4:45 ` [PATCH 1/3] diffcore-pickaxe: port optimization from has_changes() to diff_grep() Junio C Hamano
2013-04-05 4:45 ` Junio C Hamano [this message]
2013-04-05 4:45 ` [PATCH 3/3] diffcore-pickaxe: unify setup and teardown code between log -S/-G Junio C Hamano
2013-04-05 5:28 ` Jeff King
2013-04-05 5:43 ` Junio C Hamano
2013-04-05 5:45 ` Jeff King
2013-04-05 16:44 ` Junio C Hamano
2013-04-04 20:21 ` [PATCH v2 3/3] diffcore-pickaxe: respect --no-textconv Simon Ruderich
2013-04-05 7:40 ` Matthieu Moy
2013-04-05 13:16 ` [PATCH v3 " Simon Ruderich
2013-04-05 17:31 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365137126-21659-2-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).