Skip to content

Make next_token static - #143

Closed
kavyabhand wants to merge 1 commit into
codeplea:masterfrom
kavyabhand:fix/static-next-token
Closed

Make next_token static#143
kavyabhand wants to merge 1 commit into
codeplea:masterfrom
kavyabhand:fix/static-next-token

Conversation

@kavyabhand

Copy link
Copy Markdown

Summary

Marks next_token static. It is an internal lexer helper, absent from tinyexpr.h, but was accidentally exported.

Why

See #141. With -Wl,--allow-multiple-definition or LD_PRELOAD, a colliding next_token can be called instead of the lexer, and te_interp("1+2") returns a parse error instead of 3.

Test plan

  • make smoke / make smoke_pr
  • Confirm nm -g --defined-only tinyexpr.o no longer lists next_token

next_token was the only internal helper without static and is not in
tinyexpr.h. Linking against another TU that defines next_token can
silently bind the wrong function under --allow-multiple-definition or
LD_PRELOAD. Fixes accidental export; see issue discussion.
Copilot AI review requested due to automatic review settings August 2, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an accidental symbol export by giving the internal lexer helper next_token internal linkage (static), preventing external symbol interposition/collisions that can break expression parsing at runtime.

Changes:

  • Changed next_token(state *s) from external linkage to static in tinyexpr.c to ensure it is not exported as a global symbol.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codeplea

codeplea commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Fixed, thank you.

@codeplea codeplea closed this Aug 5, 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.

3 participants