Skip to content

fix: prevent nil pointer panic in parseOperator (fixes #158) - #163

Closed
AruneshDwivedi wants to merge 1 commit into
github:mainfrom
AruneshDwivedi:go-spdx-fix-nil-patch
Closed

AruneshDwivedi wants to merge 1 commit into
github:mainfrom
AruneshDwivedi:go-spdx-fix-nil-patch

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

Fixes issue #158: panic: nil-pointer dereference when parsing a dangling open parenthesis

The parseOperator function called t.peek() which can return nil when there are no more
tokens to process. Without a nil check, accessing token.role caused a panic.

Added nil check before accessing token.role in parseOperator to prevent panic on malformed
input with dangling parentheses or unexpected EOF.

This fix ensures that parsing errors are returned gracefully rather than causing a panic.

Fixes issue github#158: panic: nil-pointer dereference when parsing a dangling open parenthesis
The peek() function can return nil when there are no more tokens. Accessing token.role
on a nil pointer causes a panic. Added nil check before accessing token fields.
@elrayle

elrayle commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. This work was superseded by #168. If you feel that PR doesn't address all the potential cases, please add an issue or another PR.

@elrayle elrayle closed this Oct 8, 2026
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.

2 participants