Skip to content

purego: validate callback inputs before touching reflect - #512

Open
kumagi wants to merge 1 commit into
ebitengine:mainfrom
kumagi:fix/507-callback-panic-msg
Open

purego: validate callback inputs before touching reflect#512
kumagi wants to merge 1 commit into
ebitengine:mainfrom
kumagi:fix/507-callback-panic-msg

Conversation

@kumagi

@kumagi kumagi commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What issue is this addressing?

#507

What type of issue is this addressing?

bug

What this PR does | solves

NewCallback (unix and windows) called ty.NumIn() before checking the kind, so non-function input died inside reflect (or with a bare nil dereference) instead of the intended purego error. RegisterFunc called Value.Elem() before checking for a function pointer with the same effect. Validate first so misuse fails with actionable messages.

Closes #507

NewCallback (unix and windows) called ty.NumIn() before checking the
kind, so non-function input died inside reflect (or with a bare nil
dereference) instead of the intended purego error. RegisterFunc called
Value.Elem() before checking for a function pointer with the same
effect. Validate first so misuse fails with actionable messages.

Closes ebitengine#507

@hajimehoshi hajimehoshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hajimehoshi

Copy link
Copy Markdown
Member

@TotallyGamerJet PTAL

@TotallyGamerJet

Copy link
Copy Markdown
Collaborator

Add a test case?

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.

NewCallback/RegisterFunc panic with reflect internals (or nil deref) on non-function input

3 participants