Skip to content

Commit e33cc59

Browse files
committed
Merge branch 'maint-1.6.5' into maint
* maint-1.6.5: blame: prevent a segv when -L given start > EOF
2 parents a598331 + 92f9e27 commit e33cc59

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

builtin-blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
24332433
if (top < 1)
24342434
top = lno;
24352435
bottom--;
2436-
if (lno < top)
2436+
if (lno < top || lno < bottom)
24372437
die("file %s has only %lu lines", path, lno);
24382438

24392439
ent = xcalloc(1, sizeof(*ent));

t/t8003-blame.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,12 @@ EOF
157157
git --no-pager blame $COMMIT -- uno >/dev/null
158158
'
159159

160+
test_expect_success 'blame -L with invalid start' '
161+
test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
162+
'
163+
164+
test_expect_success 'blame -L with invalid end' '
165+
git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
166+
'
167+
160168
test_done

0 commit comments

Comments
 (0)