From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff Smith" <whydoubt@gmail.com>,
git@vger.kernel.org, "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH] blame: fix memory corruption scrambling revision name in error message
Date: Mon, 24 Jul 2017 19:06:20 +0200 [thread overview]
Message-ID: <20170724170620.19745-1-szeder.dev@gmail.com> (raw)
When attempting to blame a non-existing path, git should show an error
message like this:
$ git blame e83c51633 -- nonexisting-file
fatal: no such path nonexisting-file in e83c51633
Since the recent commit 835c49f7d (blame: rework methods that
determine 'final' commit, 2017-05-24) the revision name is either
missing or some scrambled characters are shown instead. The reason is
that the revision name must be duplicated, because it is invalidated
when the pending objects array is cleared in the meantime, but this
commit dropped the duplication.
Restore the duplication of the revision name in the affected functions
(find_single_final() and find_single_initial()).
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
blame.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/blame.c b/blame.c
index 91e26e93e..9ee0a375f 100644
--- a/blame.c
+++ b/blame.c
@@ -1662,8 +1662,8 @@ static struct commit *find_single_final(struct rev_info *revs,
found = (struct commit *)obj;
name = revs->pending.objects[i].name;
}
- if (name_p)
- *name_p = name;
+ if (name_p && name)
+ *name_p = xstrdup(name);
return found;
}
@@ -1735,7 +1735,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
die("No commit to dig up from?");
if (name_p)
- *name_p = name;
+ *name_p = xstrdup(name);
return found;
}
@@ -1843,6 +1843,8 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
if (orig)
*orig = o;
+
+ free((char *)final_commit_name);
}
--
2.14.0.rc0.88.ge338f4246
reply other threads:[~2017-07-24 17:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20170724170620.19745-1-szeder.dev@gmail.com \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=whydoubt@gmail.com \
/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).