diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 97360e73e..c36da6bcf 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -4120,6 +4120,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) } #endif +#if WASM_ENABLE_LIBC_WASI != 0 + /* + * learned from all implementations of `os_get_invalid_handle()` + * that invalid handles across all platforms are represented by -1. + */ + module->wasi_args.stdio[0] = -1; + module->wasi_args.stdio[1] = -1; + module->wasi_args.stdio[2] = -1; +#endif + return module; #if WASM_ENABLE_GC != 0 fail2: diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index e72bf94fa..3cce5543c 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -6368,6 +6368,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size) } #endif +#if WASM_ENABLE_LIBC_WASI != 0 + /* + * learned from all implementations of `os_get_invalid_handle()` + * that invalid handles across all platforms are represented by -1. + */ + module->wasi_args.stdio[0] = -1; + module->wasi_args.stdio[1] = -1; + module->wasi_args.stdio[2] = -1; +#endif + (void)ret; return module;