diff --git a/js/src/assembler/assembler/LinkBuffer.h b/js/src/assembler/assembler/LinkBuffer.h index 3f51ab371c6..57af1eda1f9 100644 --- a/js/src/assembler/assembler/LinkBuffer.h +++ b/js/src/assembler/assembler/LinkBuffer.h @@ -192,6 +192,11 @@ public: return CodeLocationLabel(code()); } + // Useful as a proxy to detect OOM. + void* unsafeCode() { + return code(); + } + protected: // Keep this private! - the underlying code should only be obtained externally via // finalizeCode() or finalizeCodeAddendum(). diff --git a/js/src/yarr/YarrJIT.cpp b/js/src/yarr/YarrJIT.cpp index f5585856dc0..2007addf2cf 100644 --- a/js/src/yarr/YarrJIT.cpp +++ b/js/src/yarr/YarrJIT.cpp @@ -2688,10 +2688,16 @@ public: backtrack(); // Link & finalize the code. - // XXX yarr-oom ExecutablePool *pool; bool ok; LinkBuffer linkBuffer(this, globalData->regexAllocator, &pool, &ok, REGEXP_CODE); + + // Attempt to detect OOM during linkBuffer creation. + if (linkBuffer.unsafeCode() == nullptr) { + jitObject.setFallBack(true); + return; + } + m_backtrackingState.linkDataLabels(linkBuffer); if (compileMode == MatchOnly) {