Skip to content

fix: handle integer suffix in #line directive without crashing#601

Merged
eliben merged 1 commit into
eliben:mainfrom
SAY-5:fix/ppline-integer-suffix-crash
May 25, 2026
Merged

fix: handle integer suffix in #line directive without crashing#601
eliben merged 1 commit into
eliben:mainfrom
SAY-5:fix/ppline-integer-suffix-crash

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 25, 2026

Copy link
Copy Markdown
Contributor

A #line directive with an integer suffix (e.g. #line 0u) caused an unhandled ValueError: invalid literal for int() with base 10: '0u' in c_lexer.py. The _decimal_constant regex already accepts suffixes like u/U/l/L, so a fuzz-generated input with a suffixed line number reaches int(pp_line) and crashes.

This wraps the int() call in a try/except ValueError and reports a proper "invalid #line directive" parse error instead. Three tests added to TestCLexerErrors.test_preprocessor covering 0u, 1U, and 10uLL.

Closes #587

Closes eliben#587

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@eliben eliben merged commit 63a4e9c into eliben:main May 25, 2026
15 checks passed
@eliben

eliben commented May 25, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution!

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.

parsing error on '0u'

2 participants