Add more checks about the imports of wasm_instance_new (#1843)

Check whether the `imports` argument is NULL in wasm_instance_new and check
the import count of each kind.

Fix issue reported by https://github.com/bytecodealliance/wasm-micro-runtime/issues/1833
This commit is contained in:
liang.he
2023-01-03 17:16:49 +08:00
committed by GitHub
parent d5aa354d41
commit bf2be805f9
3 changed files with 102 additions and 63 deletions

View File

@ -238,7 +238,7 @@ main(int argc, const char *argv[])
IMPORT_FUNCTION_LIST(CREATE_WASM_FUNCTION)
#undef CREATE_WASM_FUNCTION
wasm_extern_t *fs[10] = { 0 };
wasm_extern_t *fs[2] = { 0 };
#define ADD_TO_FUNCTION_LIST(name, index, ...) \
fs[index] = wasm_func_as_extern(function_##name);
IMPORT_FUNCTION_LIST(ADD_TO_FUNCTION_LIST)