Bug 1797685 - wasm: Fix validation condition in decodeDelegate. r=jseward

Differential Revision: https://phabricator.services.mozilla.com/D161087
This commit is contained in:
Ryan Hunt 2022-11-19 16:19:14 +00:00
Родитель 80078e3ba1
Коммит 3b826f2d65
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -1631,21 +1631,21 @@ inline bool OpIter<Policy>::readDelegate(uint32_t* relativeDepth,
ValueVector* tryResults) {
MOZ_ASSERT(Classify(op_) == OpKind::Delegate);
uint32_t originalDepth;
if (!readVarU32(&originalDepth)) {
return fail("unable to read delegate depth");
}
Control& block = controlStack_.back();
if (block.kind() != LabelKind::Try) {
return fail("delegate can only be used within a try");
}
uint32_t delegateDepth;
if (!readVarU32(&delegateDepth)) {
return fail("unable to read delegate depth");
}
// Depths for delegate start counting in the surrounding block.
*relativeDepth = originalDepth + 1;
if (*relativeDepth >= controlStack_.length()) {
if (delegateDepth >= controlStack_.length() - 1) {
return fail("delegate depth exceeds current nesting level");
}
*relativeDepth = delegateDepth + 1;
// Because `delegate` acts like `end` and ends the block, we will check
// the stack here.