Skip to content

fix: prevent huge line range allocation - #4041

Open
vardaanexe wants to merge 2 commits into
sharkdp:masterfrom
vardaanexe:master
Open

vardaanexe wants to merge 2 commits into
sharkdp:masterfrom
vardaanexe:master

Conversation

@vardaanexe

Copy link
Copy Markdown

What does this PR do?

Prevents bat from attempting an excessively large memory allocation when a huge negative --line-range value is provided.

What changed?

  • Caps the initial VecDeque capacity at 1024 lines.
  • Adds a regression test for a huge negative --line-range.
  • Existing line-range behavior remains unchanged.

Testing

  • cargo test line_range_huge_negative_does_not_panic
  • cargo test line_range_context_very_large
  • git diff --check

All tests pass.

Fixes #4039

This branch has not been deployed

No deployments
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.

Capacity overflow panic with huge negative --line-range on macOS

1 participant