Skip to content

Commit 0f3872a

Browse files
committed
Fix panic with empty input in LineReaderAt
1 parent fa88623 commit 0f3872a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

gitdiff/io.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (r *lineReaderAt) ReadLinesAt(lines [][]byte, offset int64) (n int, err err
4747
return 0, err
4848
}
4949
}
50-
if startLine > int64(len(r.index)) {
50+
if startLine >= int64(len(r.index)) {
5151
return 0, io.EOF
5252
}
5353

gitdiff/io_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ func TestLineReaderAt(t *testing.T) {
4848
EOF: true,
4949
EOFCount: 4,
5050
},
51+
"emptyInput": {
52+
InputLines: 0,
53+
Offset: 0,
54+
Count: 2,
55+
EOF: true,
56+
EOFCount: 0,
57+
},
5158
"offsetAfterEOF": {
5259
InputLines: 8,
5360
Offset: 10,

0 commit comments

Comments
 (0)