From c28d9ef68de57b5b0b8149f0af8d62cf66546aa1 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 20 Jun 2019 17:41:35 +0300 Subject: [PATCH] C: fix GC hanging when main function receives 0 for argc --- core/src/main/resources/org/teavm/backend/c/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/org/teavm/backend/c/runtime.c b/core/src/main/resources/org/teavm/backend/c/runtime.c index 5afdbc794..8027981b6 100644 --- a/core/src/main/resources/org/teavm/backend/c/runtime.c +++ b/core/src/main/resources/org/teavm/backend/c/runtime.c @@ -459,7 +459,7 @@ char* teavm_char16ToMb(char16_t* javaChars, int32_t length) { } TeaVM_Array* teavm_parseArguments(int argc, char** argv) { - TeaVM_Array* array = teavm_allocateStringArray(argc - 1); + TeaVM_Array* array = teavm_allocateStringArray(max(argc - 1, 0)); TeaVM_String** arrayData = TEAVM_ARRAY_DATA(array, TeaVM_String*); for (int i = 1; i < argc; ++i) { arrayData[i - 1] = teavm_cToString(argv[i]);