From 0f5f3c30490741c3053627de4fd5a27964c9953c Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 9 Jun 2019 16:36:59 -0400 Subject: 1336783 - followup: Fix rooting. --- js/src/frontend/Parser.cpp | 58 +++++++++++++++++++++++++--------------------- js/src/frontend/Parser.h | 10 ++++---- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 82057f62e8..322f428e51 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -8617,8 +8617,8 @@ Parser::newName(PropertyName* name, TokenPos pos) } template -PropertyName* -Parser::checkLabelOrIdentifierReference(PropertyName* ident, +bool +Parser::checkLabelOrIdentifierReference(HandlePropertyName ident, uint32_t offset, YieldHandling yieldHandling) { @@ -8627,81 +8627,81 @@ Parser::checkLabelOrIdentifierReference(PropertyName* ident, versionNumber() >= JSVERSION_1_7) { errorAt(offset, JSMSG_RESERVED_ID, "yield"); - return nullptr; + return false; } if (pc->sc()->needStrictChecks()) { if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "yield")) - return nullptr; + return false; } - return ident; + return true; } if (ident == context->names().await) { if (awaitIsKeyword()) { errorAt(offset, JSMSG_RESERVED_ID, "await"); - return nullptr; + return false; } - return ident; + return true; } if (IsKeyword(ident) || IsReservedWordLiteral(ident)) { errorAt(offset, JSMSG_INVALID_ID, ReservedWordToCharZ(ident)); - return nullptr; + return false; } if (IsFutureReservedWord(ident)) { errorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident)); - return nullptr; + return false; } if (pc->sc()->needStrictChecks()) { if (IsStrictReservedWord(ident)) { if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident))) - return nullptr; - return ident; + return false; + return true; } if (ident == context->names().let) { if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "let")) - return nullptr; - return ident; + return false; + return true; } if (ident == context->names().static_) { if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "static")) - return nullptr; - return ident; + return false; + return true; } } - return ident; + return true; } template -PropertyName* -Parser::checkBindingIdentifier(PropertyName* ident, +bool +Parser::checkBindingIdentifier(HandlePropertyName ident, uint32_t offset, YieldHandling yieldHandling) { if (!checkLabelOrIdentifierReference(ident, offset, yieldHandling)) - return nullptr; + return false; if (pc->sc()->needStrictChecks()) { if (ident == context->names().arguments) { if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "arguments")) - return nullptr; - return ident; + return false; + return true; } if (ident == context->names().eval) { if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "eval")) - return nullptr; - return ident; + return false; + return true; } } - return ident; + return true; } template @@ -8715,14 +8715,20 @@ Parser::labelOrIdentifierReference(YieldHandling yieldHandling) // // Use PropertyName* instead of TokenKind to reflect the normalization. - return checkLabelOrIdentifierReference(tokenStream.currentName(), pos().begin, yieldHandling); + RootedPropertyName ident(context, tokenStream.currentName()); + if (!checkLabelOrIdentifierReference(ident, pos().begin, yieldHandling)) + return nullptr; + return ident; } template PropertyName* Parser::bindingIdentifier(YieldHandling yieldHandling) { - return checkBindingIdentifier(tokenStream.currentName(), pos().begin, yieldHandling); + RootedPropertyName ident(context, tokenStream.currentName()); + if (!checkBindingIdentifier(ident, pos().begin, yieldHandling)) + return nullptr; + return ident; } template diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index d53a64eebd..4eb0f5a393 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -1331,14 +1331,14 @@ class Parser final : public ParserBase, private JS::AutoGCRooter Node classDefinition(YieldHandling yieldHandling, ClassContext classContext, DefaultHandling defaultHandling); - PropertyName* checkLabelOrIdentifierReference(PropertyName* ident, - uint32_t offset, - YieldHandling yieldHandling); - - PropertyName* checkBindingIdentifier(PropertyName* ident, + bool checkLabelOrIdentifierReference(HandlePropertyName ident, uint32_t offset, YieldHandling yieldHandling); + bool checkBindingIdentifier(HandlePropertyName ident, + uint32_t offset, + YieldHandling yieldHandling); + PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling); PropertyName* labelIdentifier(YieldHandling yieldHandling) { -- cgit v1.2.3