From 8dfefb46d10b3004d2f07d4e8976680ad9a79208 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Wed, 5 May 2021 08:33:16 -0700 Subject: [PATCH] wasi: do not crash if argc is 0 Instead, leave args at its default value (which provides a fake argv[0] as it has for a long time). linux and mac do not seem affected. Fixes #1862 (tinygo apps after v0.17.0-113-g7b761fa crash if run without argv[0]) --- src/runtime/runtime_wasm_wasi.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/runtime_wasm_wasi.go b/src/runtime/runtime_wasm_wasi.go index 02fa0260..b1a58886 100644 --- a/src/runtime/runtime_wasm_wasi.go +++ b/src/runtime/runtime_wasm_wasi.go @@ -30,6 +30,9 @@ func init() { // these args (argv). var argc, argv_buf_size uint32 args_sizes_get(&argc, &argv_buf_size) + if argc == 0 { + return + } // Obtain the command line arguments argsSlice := make([]unsafe.Pointer, argc)