From b060fc48a4a17d120ab2718da0b32994361c9c00 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Mon, 12 Apr 2021 00:52:45 +0300 Subject: [PATCH] Call m3_FreeModule in fuzzer --- platforms/app_fuzz/fuzzer.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/platforms/app_fuzz/fuzzer.c b/platforms/app_fuzz/fuzzer.c index 86a1ee6..882addf 100644 --- a/platforms/app_fuzz/fuzzer.c +++ b/platforms/app_fuzz/fuzzer.c @@ -9,19 +9,13 @@ #include #include "wasm3.h" -#include "m3_api_wasi.h" -#include "m3_api_libc.h" -#include "m3_env.h" - #define FATAL(...) __builtin_trap() - int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { M3Result result = m3Err_none; - IM3Environment env = m3_NewEnvironment (); if (env) { IM3Runtime runtime = m3_NewRuntime (env, 64*1024, NULL); @@ -31,20 +25,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if (module) { result = m3_LoadModule (runtime, module); if (result == 0) { - /* - result = m3_LinkWASI (runtime->modules); - if (result) FATAL("m3_LinkWASI: %s", result); - - result = m3_LinkLibC (runtime->modules); - if (result) FATAL("m3_LinkLibC: %s", result); - */ IM3Function f = NULL; result = m3_FindFunction (&f, runtime, "fib"); if (f) { m3_CallV (f, 10); } + } else { + m3_FreeModule (module); } - } m3_FreeRuntime(runtime);