From c6438d0d4457dc4d83279f6d34f622cd9a28f485 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 30 Jan 2020 22:22:05 +0100 Subject: [PATCH] fuzz: Don't panic on module compilation errors (#875) Let's avoid having two phases of checks and just ignore the module compilation errors during the instantiate oracle, only relying on one check. --- crates/fuzzing/src/oracles.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs index c7d9ecfb10..5b1b79ed5a 100644 --- a/crates/fuzzing/src/oracles.rs +++ b/crates/fuzzing/src/oracles.rs @@ -23,10 +23,6 @@ use wasmtime::*; /// /// You can control which compiler is used via passing a `Strategy`. pub fn instantiate(wasm: &[u8], strategy: Strategy) { - if wasmparser::validate(wasm, None).is_err() { - return; - } - let mut config = Config::new(); config .strategy(strategy) @@ -34,7 +30,10 @@ pub fn instantiate(wasm: &[u8], strategy: Strategy) { let engine = Engine::new(&config); let store = Store::new(&engine); - let module = Module::new(&store, wasm).expect("Failed to compile a valid Wasm module!"); + let module = match Module::new(&store, wasm) { + Ok(module) => module, + Err(_) => return, + }; let imports = match dummy_imports(&store, module.imports()) { Ok(imps) => imps,