Skip to content

fix(taglist): avoid usize underflow on empty tag list#2972

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

fix(taglist): avoid usize underflow on empty tag list#2972
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/taglist-empty-underflow-clean

Conversation

@Noethix55555

Copy link
Copy Markdown

In move_selection, max_selection is computed as tags.len() - 1. When the tag list is an empty Vec, this underflows: panic in debug builds, usize::MAX in release (causing an out-of-bounds selection).

Fix: use saturating_sub(1) so the result is 0 for an empty list.

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