Bug 1640475: Report OOM in initializeNamedCaptures r=mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D76956
This commit is contained in:
Iain Ireland 2020-05-27 20:20:30 +00:00
parent 7b6180750d
commit f3489ed171
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,9 @@
// |jit-test| skip-if: !('oomTest' in this)
var i = 0;
oomTest(function() {
for (var j = 0; j < 10; ++j) {
var r = RegExp(`(?<_${(i++).toString(32)}>a)`);
r.exec("a");
}
});

View File

@ -1180,6 +1180,7 @@ bool RegExpShared::initializeNamedCaptures(JSContext* cx, HandleRegExpShared re,
uint32_t arraySize = numNamedCaptures * sizeof(uint32_t);
uint32_t* captureIndices = static_cast<uint32_t*>(js_malloc(arraySize));
if (!captureIndices) {
js::ReportOutOfMemory(cx);
return false;
}