mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
blame: prevent a segv when -L given start > EOF
blame would segv if given -L <lineno> with <lineno> past the end of the file. While we're fixing the bug, add test cases for an invalid <start> when called as -L <start>,<end> or -L<start>. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
153559a964
commit
92f9e273e8
|
@ -2432,7 +2432,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
|
|||
if (top < 1)
|
||||
top = lno;
|
||||
bottom--;
|
||||
if (lno < top)
|
||||
if (lno < top || lno < bottom)
|
||||
die("file %s has only %lu lines", path, lno);
|
||||
|
||||
ent = xcalloc(1, sizeof(*ent));
|
||||
|
|
|
@ -157,4 +157,12 @@ EOF
|
|||
git --no-pager blame $COMMIT -- uno >/dev/null
|
||||
'
|
||||
|
||||
test_expect_success 'blame -L with invalid start' '
|
||||
test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
|
||||
'
|
||||
|
||||
test_expect_success 'blame -L with invalid end' '
|
||||
git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue