Skip to content

Commit

Permalink
Merge pull request #3726 from b4n/erlang-invalid-pointer
Browse files Browse the repository at this point in the history
erlang: Fix crash parsing directives longer than 31 characters
  • Loading branch information
masatake committed May 20, 2023
2 parents 3547021 + 8e218a3 commit dfabddc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit dfabddc

Please sign in to comment.