Skip to content

fix: avoid index-out-of-bounds panic in staging apply_selection#2955

Open
SAY-5 wants to merge 1 commit into
gitui-org:masterfrom
SAY-5:say-fix-staging-oob
Open

fix: avoid index-out-of-bounds panic in staging apply_selection#2955
SAY-5 wants to merge 1 commit into
gitui-org:masterfrom
SAY-5:say-fix-staging-oob

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 21, 2026

This Pull Request fixes/closes #2953.

It changes the following:

  • NewFromOldContent::add_old_line and catchup_to_hunkstart no longer index old_lines past its length, so unstaging or discarding lines near the end of a diff returns the working content unchanged instead of aborting with index out of bounds.
  • Added two unit tests against NewFromOldContent that exercise the previously panicking path.

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

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.

Index out of bounds

1 participant