Skip to content

fix(blame): avoid underflow when blaming an empty file#2969

Open
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/blame-empty-file-underflow
Open

fix(blame): avoid underflow when blaming an empty file#2969
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/blame-empty-file-underflow

Conversation

@Noethix55555

Copy link
Copy Markdown

When an empty file has been committed, git blame succeeds and returns 0 lines. Two sites in blame_file.rs compute lines().len() - 1 without guarding against the empty case, causing a usize underflow: panic in debug builds, usize::MAX in release.

Fixed both get_max_line_number and the goto-line event handler to use saturating_sub(1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant