Skip to content

Commit

Permalink
Fix an un-expanded type in table init exprs (#831)
Browse files Browse the repository at this point in the history
This fixes a recent fuzz-bug found from #823 where initialization
expressions needed to be expanded before resolution.
  • Loading branch information
alexcrichton committed Nov 21, 2022
1 parent c280be6 commit 74e3029
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/wast/src/core/resolve/types.rs
Expand Up @@ -103,8 +103,16 @@ impl<'a> Expander<'a> {
}
},

ModuleField::Table(_)
| ModuleField::Memory(_)
ModuleField::Table(t) => match &mut t.kind {
TableKind::Normal { init_expr, .. } => {
if let Some(expr) = init_expr {
self.expand_expression(expr);
}
}
TableKind::Import { .. } | TableKind::Inline { .. } => {}
},

ModuleField::Memory(_)
| ModuleField::Start(_)
| ModuleField::Export(_)
| ModuleField::Custom(_) => {}
Expand Down
13 changes: 13 additions & 0 deletions tests/local/invalid-init-expr.wast
@@ -0,0 +1,13 @@
(assert_invalid
(module
(table funcref (elem (call_indirect)))
)
"non-constant operator")

(assert_invalid
(module
(table 1 1 funcref (call_indirect))
)
;; note that this error message will change when wasmparser implements the
;; above feature
"invalid value type")

0 comments on commit 74e3029

Please sign in to comment.