fix: prevent nil pointer crash when extracting with no current node#706
Open
ricardbejarano wants to merge 1 commit into
Open
fix: prevent nil pointer crash when extracting with no current node#706ricardbejarano wants to merge 1 commit into
ricardbejarano wants to merge 1 commit into
Conversation
extractFile called node.Path() without checking whether CurrentNode returned nil, segfaulting when there is no node at the cursor position (e.g. an active filter matches nothing). Guard against a nil node and return early, matching the existing pattern in the viewmodel's CursorLeft and similar navigation methods. Fixes wagoodman#620 Signed-off-by: bejaratommy <tommy@bejara.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
extractFile(the Ctrl+E action in the file tree view) callednode.Path()on the result ofCurrentNode(...)without checking fornil. When there is no node at the current cursor position — for example when an active filter matches nothing —CurrentNodereturnsniland dive segfaults:Fix
Guard against a
nilnode and return early, matching the existing pattern already used by the viewmodel's navigation methods (e.g.CursorLeft), which all bail out whengetAbsPositionNodereturnsnil.Notes
Fixes #620 (reproduced and confirmed independently by another user in the issue thread). The change is a localized nil check; the affected view package has no unit tests (the views depend on a live gocui runtime), so I relied on CI for verification.