diff options
author | Clemens Buchacher <drizzd@aon.at> | 2013-05-28 00:49:57 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-28 11:26:24 -0700 |
commit | 46ec510ac088ac2669e617a4c8c35e6218dabecc (patch) | |
tree | 31bd560c6e1c11bd5d56c29067fa9640f4bb1c0d /combine-diff.c | |
parent | 04a74b6cfa5ef4870263f84ac94a488d9f2ef14a (diff) | |
download | git-46ec510ac088ac2669e617a4c8c35e6218dabecc.tar.gz git-46ec510ac088ac2669e617a4c8c35e6218dabecc.tar.xz |
fix segfault with git log -c --follow
In diff_tree_combined we make a copy of diffopts. In
try_to_follow_renames, called via diff_tree_sha1, we free and
re-initialize diffopts->pathspec->items. Since we did not make a deep
copy of diffopts in diff_tree_combined, the original diffopts does not
get the update. By the time we return from diff_tree_combined,
rev->diffopt->pathspec->items points to an invalid memory address. We
get a segfault next time we try to access that pathspec.
Instead, along with the copy of diffopts, make a copy pathspec->items as
well.
We would also have to make a copy of pathspec->raw to keep it consistent
with pathspec->items, but nobody seems to rely on that.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'combine-diff.c')
-rw-r--r-- | combine-diff.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/combine-diff.c b/combine-diff.c index 7f6187f9c..21fd00ff6 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1120,6 +1120,7 @@ void diff_tree_combined(const unsigned char *sha1, int i, num_paths, needsep, show_log_first, num_parent = parents->nr; diffopts = *opt; + diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts); diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; DIFF_OPT_SET(&diffopts, RECURSIVE); DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL); @@ -1187,6 +1188,8 @@ void diff_tree_combined(const unsigned char *sha1, paths = paths->next; free(tmp); } + + diff_tree_release_paths(&diffopts); } void diff_tree_combined_merge(const struct commit *commit, int dense, |