Skip to content

Fix crash on non-ASCII list marker lookahead; use ASCII digit range - #252

Closed
westito wants to merge 1 commit into
tree-sitter-grammars:split_parserfrom
westito:fix/isdigit-lookahead-crt-assert
Closed

westito wants to merge 1 commit into
tree-sitter-grammars:split_parserfrom
westito:fix/isdigit-lookahead-crt-assert

Conversation

@westito

@westito westito commented Jul 16, 2026

Copy link
Copy Markdown
image

parse_ordered_list_marker() passed lexer->lookahead (a full Unicode codepoint, e.g. 8211 for an en dash) directly to isdigit(). On the Windows debug CRT this trips the assertion 'c >= -1 && c <= 255' in isctype.cpp, crashing any consumer that parses markdown containing non-ASCII characters.

CommonMark ordered-list markers are ASCII digits 0-9 only, which is also exactly what isdigit() matches in the C locale, so replace the isdigit() calls with a direct '0'..'9' range check. This preserves grammar behavior while removing the locale/ctype dependency and the out-of-range codepoint crash.

parse_ordered_list_marker() passed lexer->lookahead (a full Unicode
codepoint, e.g. 8211 for an en dash) directly to isdigit(). On the
Windows debug CRT this trips the assertion 'c >= -1 && c <= 255' in
isctype.cpp, crashing any consumer that parses markdown containing
non-ASCII characters.

CommonMark ordered-list markers are ASCII digits 0-9 only, which is
also exactly what isdigit() matches in the C locale, so replace the
isdigit() calls with a direct '0'..'9' range check. This preserves
grammar behavior while removing the locale/ctype dependency and the
out-of-range codepoint crash.
@clason

clason commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you, but this is really an upstream issue (improper use of locales) that needs to be solved there. See tree-sitter/tree-sitter#5255

@WillLillis

@westito

westito commented Jul 16, 2026

Copy link
Copy Markdown
Author

Ah okay, thank you!

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