Skip to content

Commit 19b9c8e

Browse files
committed
queries: Fix panic from syntax error at the end of a query file
`line_end` could be the last byte in the file so `line_end + 1` could cause a panic. We can be defensive and use `str::get` instead.
1 parent 613e45b commit 19b9c8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bindings/src/query.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ impl ParserErrorLocation {
375375
.next_back()
376376
.filter(|s| !s.is_empty())
377377
.map(ToOwned::to_owned);
378-
line_after = source[line_end + 1..]
379-
.lines()
380-
.next()
378+
line_after = source
379+
.get(line_end + 1..)
380+
.and_then(|rest| rest.lines().next())
381381
.filter(|s| !s.is_empty())
382382
.map(ToOwned::to_owned);
383383
break;

0 commit comments

Comments
 (0)