Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2010-09-27 21:29:45 +0400
committerJunio C Hamano <gitster@pobox.com>2010-09-27 21:39:54 +0400
commit6355e505bacf0a12a5de77bcd0c1198e74ad340b (patch)
treec1e13fda5177484fa34872ff4dc9cba2245f5df3 /builtin
parent9027fa9eb7df606b6658dd48a40bb993ce222ddd (diff)
builtin/revert.c: don't dereference a NULL pointer
cherry-pick will segfault when transplanting a root commit if the --ff option is used. This happens because the "parent" pointer is set to NULL when the commit being cherry-picked has no parents. Later, when "parent" is dereferenced, the cherry-pick segfaults. Fix this by checking whether "parent" is NULL before dereferencing it and add a test for this case of cherry-picking a root commit with --ff. Reported-by: Zbyszek Szmek <zbyszek@in.waw.pl> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/revert.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index 4b47ace36b..57b51e4a0e 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -442,7 +442,7 @@ static int do_pick_commit(void)
else
parent = commit->parents->item;
- if (allow_ff && !hashcmp(parent->object.sha1, head))
+ if (allow_ff && parent && !hashcmp(parent->object.sha1, head))
return fast_forward_to(commit->object.sha1, head);
if (parent && parse_commit(parent) < 0)