Skip to content

Commit

Permalink
Bug 1362154: Part 2: Avoid rooting hazard in CheckPatternSyntax r=mga…
Browse files Browse the repository at this point in the history
…udet

In debug, CheckPatternSyntax holds an unrooted RegExpShared across a call to the regexp parser. This is the only remaining obstacle to allocating GC things while parsing regexps.

Differential Revision: https://phabricator.services.mozilla.com/D76034
  • Loading branch information
iainireland committed May 20, 2020
1 parent f52b78c commit ef12bf0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/src/builtin/RegExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ static RegExpShared* CheckPatternSyntax(JSContext* cx, HandleAtom pattern,
// If we already have a RegExpShared for this pattern/flags, we can
// avoid the much slower CheckPatternSyntaxSlow call.

if (RegExpShared* shared = cx->zone()->regExps().maybeGet(pattern, flags)) {
RootedRegExpShared shared(cx, cx->zone()->regExps().maybeGet(pattern, flags));
if (shared) {
#ifdef DEBUG
// Assert the pattern is valid.
if (!CheckPatternSyntaxSlow(cx, pattern, flags)) {
Expand Down

0 comments on commit ef12bf0

Please sign in to comment.