Skip to content

Skip nil StructReflector fields before calling their method - #451

Open
Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-nil-reflector
Open

Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-nil-reflector

Conversation

@Aschenbath

Copy link
Copy Markdown

Describe the pull request

ReflectFrom calls ReflectINIStruct on nil pointer fields before reaching the existing nil-pointer guard. An optional custom reflector whose method reads its receiver therefore panics instead of being skipped like other nil pointer fields.

Move the guard ahead of custom reflector dispatch. The regression covers an absent reflector, a populated reflector, and the field following it.

Link to the issue: n/a

Validation: the added regression fails on main with a nil receiver panic and passes with this change. go test -count=1 ./..., go vet ./..., gofmt, and git diff --check pass on Go 1.26.11, Windows/amd64.

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code.

AI usage

OpenAI Codex assisted with investigation, implementation, regression tests, validation, and review of the final diff.

@Aschenbath
Aschenbath requested a review from unknwon as a code owner November 24, 2026 15:56

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.

1 participant