Skip to content

Commit

Permalink
Fix potential crash when parsing build logs (#973)
Browse files Browse the repository at this point in the history
When encountering an error in the build log file, the server tries to convert the line number into a (zero)-based offset. 
If the line number is (for some reason) completely wrong, a panic in the server can occur.
  • Loading branch information
pfoerster authored Dec 3, 2023
1 parent b11a150 commit 6c785a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Do not report `undefined reference` errors when using `\nocite{*}` ([#964](https://github.com/latex-lsp/texlab/issues/964))
- Fix potential crash when parsing build log files ([#973](https://github.com/latex-lsp/texlab/issues/973))

## [5.11.0] - 2023-11-05

Expand Down
2 changes: 1 addition & 1 deletion crates/line-index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl LineIndex {
}

pub fn offset(&self, line_col: LineCol) -> Option<TextSize> {
Some(self.newlines[line_col.line as usize] + TextSize::from(line_col.col))
Some(self.newlines.get(line_col.line as usize)? + TextSize::from(line_col.col))
}

pub fn to_utf16(&self, line_col: LineCol) -> Option<LineColUtf16> {
Expand Down

0 comments on commit 6c785a6

Please sign in to comment.