summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-06-03 12:07:38 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-06-03 12:16:30 -0700
commitcfc0029a95c8be562a595adb507b0aa171f01a31 (patch)
tree4f5f1e7a0d0e62d276229277eaad1f524aab484e /src
parentf0e79fc18be7013f43f79317836dc71d623c40d6 (diff)
downloadbinaryen-cfc0029a95c8be562a595adb507b0aa171f01a31.tar.gz
binaryen-cfc0029a95c8be562a595adb507b0aa171f01a31.tar.bz2
binaryen-cfc0029a95c8be562a595adb507b0aa171f01a31.zip
check calls more carefully in validator
Diffstat (limited to 'src')
-rw-r--r--src/wasm-validator.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 39eaca572..5e7b60498 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -93,23 +93,26 @@ public:
shouldBeTrue(curr->condition->type == unreachable || curr->condition->type == i32, curr, "br_table condition must be i32");
}
void visitCall(Call *curr) {
- auto* target = getModule()->getFunction(curr->target);
- shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match");
+ auto* target = getModule()->checkFunction(curr->target);
+ if (!shouldBeTrue(!!target, curr, "call target must exist")) return;
+ if (!shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match");
}
}
void visitCallImport(CallImport *curr) {
- auto* target = getModule()->getImport(curr->target)->type;
- shouldBeTrue(curr->operands.size() == target->params.size(), curr, "call param number must match");
+ auto* import = getModule()->checkImport(curr->target);
+ if (!shouldBeTrue(!!import, curr, "call_import target must exist")) return;
+ auto* type = import->type;
+ if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
- shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, target->params[i], curr, "call param types must match");
+ shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
}
}
void visitCallIndirect(CallIndirect *curr) {
auto* type = curr->fullType;
shouldBeEqualOrFirstIsUnreachable(curr->target->type, i32, curr, "indirect call target must be an i32");
- shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match");
+ if (!shouldBeTrue(curr->operands.size() == type->params.size(), curr, "call param number must match")) return;
for (size_t i = 0; i < curr->operands.size(); i++) {
shouldBeEqualOrFirstIsUnreachable(curr->operands[i]->type, type->params[i], curr, "call param types must match");
}