Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erlang: Fix crash parsing directives longer than 31 characters #3726

Merged
merged 1 commit into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Units/parser-erlang.r/crash1.d/input.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
% long directives used to possibly crash the parser
% (and always make Valgrind angry)
-some_extremely_loooong_directive
-even_longer_might_crash_more_often_than_not_but_anyway_valgrind_would_not_be_hayyp_either_way

2 changes: 1 addition & 1 deletion parsers/erlang.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ static void parseDirective (const unsigned char *cp, vString *const module)
* Record definitions are handled separately
*/
vString *const directive = vStringNew ();
const char *const drtv = vStringValue (directive);
cp = parseIdentifier (cp, directive);
cp = skipSpace (cp);
if (*cp == '(')
++cp;

const char *const drtv = vStringValue (directive);
if (strcmp (drtv, "record") == 0)
parseSimpleTag (cp, K_RECORD);
else if (strcmp (drtv, "define") == 0)
Expand Down