Skip to content

Commit

Permalink
JavaScript: avoid assertion failures when making an empty tag
Browse files Browse the repository at this point in the history
Related to #900, #1112, and #3427.

When the parser tries making a tag with empty name, an assertion
in registerEntry fails. The parser side should be fixed but it
will take a time. This change puts guard conditions around
registerEntry to avoid the failures.

THIS IS A TEMPORARILY SOLUTION.

Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Jul 5, 2022
1 parent b6ac374 commit cf68aae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Units/parser-javascript.r/tagging-empty-name.d/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is a crash test.
See #900, #1112, and #3427.
1 change: 1 addition & 0 deletions Units/parser-javascript.r/tagging-empty-name.d/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const
12 changes: 10 additions & 2 deletions parsers/jscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,11 @@ static int makeJsRefTagsForNameChain (char *name_chain, const tokenInfo *token,
e.extensionFields.scopeIndex = scope;

index = makeTagEntry (&e);
registerEntry (index);
/* We shold remove This condition. We should fix the callers passing
* an empty name instead. makeTagEntry() returns CORK_NIL if the tag
* name is empty. */
if (index != CORK_NIL)
registerEntry (index);
}

return next
Expand Down Expand Up @@ -556,7 +560,11 @@ static int makeJsTagCommon (const tokenInfo *const token, const jsKind kind,
markTagExtraBit (&e, XTAG_ANONYMOUS);

index = makeTagEntry (&e);
registerEntry (index);
/* We shold remove This condition. We should fix the callers passing
* an empty name instead. makeTagEntry() returns CORK_NIL if the tag
* name is empty. */
if (index != CORK_NIL)
registerEntry (index);

return index;
}
Expand Down

0 comments on commit cf68aae

Please sign in to comment.