rev-parse: check lookup'ed commit references for NULL
Commits2122f8b963
("rev-parse: Add support for the ^! and ^@ syntax", 2008-07-26) and3dd4e7320d
("Teach rev-parse the ... syntax.", 2006-07-04) taught rev-parse new syntax, and used lookup_commit_reference() as part of their logic. Neither usage checked the returned commit to see if it was non-NULL before using it. Check for NULL and ensure an appropriate error is reported to the user. Reported by Florian Weimer and Todd Zullinger. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Elijah Newren <newren@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d32eb83c1d
commit
0ed556d38f
@ -214,4 +214,12 @@ test_expect_success 'rev-list merge^-1x (garbage after ^-1)' '
|
||||
test_must_fail git rev-list merge^-1x
|
||||
'
|
||||
|
||||
test_expect_success 'rev-parse $garbage^@ does not segfault' '
|
||||
test_must_fail git rev-parse $EMPTY_TREE^@
|
||||
'
|
||||
|
||||
test_expect_success 'rev-parse $garbage...$garbage does not segfault' '
|
||||
test_must_fail git rev-parse $EMPTY_TREE...$EMPTY_BLOB
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user