stb_c_lexer crash
crash when parse source NOT endswith newline.
// main helper function for returning a parsed token static int stb__clex_token(stb_lexer *lexer, int token, char *start, char *end) { lexer->token = token; lexer->where_firstchar = start; lexer->where_lastchar = end; lexer->parse_point = end+1; <---- here, fix ----> (end == lexer->eof) ? end : end+1 return 1; }
Ugh, it looks like stb_c_lexer has never actually been tested on non-NUL-terminated input strings, and has buffer overruns in most paths when handed such an input.
Until this is resolved, I would recommend only using stb_c_lexer on inputs that have a terminating NUL added.
My test already used NUL-terminated string... it maybe another bug
Yes, you're right, I think it's just the bug you describe in stb__clex_token.
I would like to work on that, is there already a pull request on that? If not, is there anything else I should keep in mind?