Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: test/unittests/wasm/ast-decoder-unittest.cc

Issue 2271803004: [wasm] Bound the allowed number of locals. (Closed)
Patch Set: Add a constant for the limit and test it. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/wasm/ast-decoder-unittest.cc
diff --git a/test/unittests/wasm/ast-decoder-unittest.cc b/test/unittests/wasm/ast-decoder-unittest.cc
index 7311f063a0ad8984ab47808cd8120ecb8dd8decb..dd5a7ab6243929e6078ed68f6b5c2f914ded5ed0 100644
--- a/test/unittests/wasm/ast-decoder-unittest.cc
+++ b/test/unittests/wasm/ast-decoder-unittest.cc
@@ -238,6 +238,11 @@ TEST_F(AstDecoderTest, GetLocal0_local) {
EXPECT_VERIFIES(sigs.i_v(), kCodeGetLocal0);
}
+TEST_F(AstDecoderTest, TooManyLocals) {
+ AddLocals(kAstI32, 4034986500);
+ EXPECT_FAILURE(sigs.i_v(), kCodeGetLocal0);
+}
+
TEST_F(AstDecoderTest, GetLocal0_param_n) {
FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()};
@@ -269,8 +274,23 @@ TEST_F(AstDecoderTest, GetLocal_off_end) {
EXPECT_FAILURE(sigs.i_i(), code);
}
+TEST_F(AstDecoderTest, NumLocalBelowLimit) {
+ AddLocals(kAstI32, kMaxNumWasmLocals - 1);
+ EXPECT_VERIFIES_INLINE(sigs.v_v(), WASM_NOP);
+}
+
+TEST_F(AstDecoderTest, NumLocalAtLimit) {
+ AddLocals(kAstI32, kMaxNumWasmLocals);
+ EXPECT_VERIFIES_INLINE(sigs.v_v(), WASM_NOP);
+}
+
+TEST_F(AstDecoderTest, NumLocalAboveLimit) {
+ AddLocals(kAstI32, kMaxNumWasmLocals + 1);
+ EXPECT_FAILURE_INLINE(sigs.v_v(), WASM_NOP);
+}
+
TEST_F(AstDecoderTest, GetLocal_varint) {
- const int kMaxLocals = 8000000;
+ const int kMaxLocals = kMaxNumWasmLocals;
AddLocals(kAstI32, kMaxLocals);
for (int index = 0; index < kMaxLocals; index = index * 11 + 5) {
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698