diff --git a/runtime/src/launcher/cpp/launcher.cpp b/runtime/src/launcher/cpp/launcher.cpp index f59197a904c..bd32b1b58ec 100644 --- a/runtime/src/launcher/cpp/launcher.cpp +++ b/runtime/src/launcher/cpp/launcher.cpp @@ -9,7 +9,7 @@ ArrayHeader* setupArgs(int argc, char** argv) { ArrayHeader* args = AllocArrayInstance(theArrayTypeInfo, SCOPE_GLOBAL, argc-1); for (int i = 0; i < argc-1; i++) { - Kotlin_Array_set(args, i, AllocStringInstance( argv[i+1] )); + Kotlin_Array_set(args, i, AllocStringInstance( argv[i+1], strlen(argv[i+1]) )); } return args; diff --git a/runtime/src/main/cpp/Memory.cpp b/runtime/src/main/cpp/Memory.cpp index b0caebf0b2c..2c90ad9bd45 100644 --- a/runtime/src/main/cpp/Memory.cpp +++ b/runtime/src/main/cpp/Memory.cpp @@ -89,12 +89,11 @@ ArrayHeader* AllocArrayInstance( return ArrayContainer(type_info, elements).GetPlace(); } -ArrayHeader* AllocStringInstance(const char* cstring) { - uint32_t length = strlen(cstring); +ArrayHeader* AllocStringInstance(const char* data, uint32_t length) { ArrayHeader* result = ArrayContainer(theStringTypeInfo, length).GetPlace(); memcpy( ByteArrayAddressOfElementAt(result, 0), - cstring, + data, length); return result; } diff --git a/runtime/src/main/cpp/Memory.h b/runtime/src/main/cpp/Memory.h index c66054d0387..f45b8f38379 100644 --- a/runtime/src/main/cpp/Memory.h +++ b/runtime/src/main/cpp/Memory.h @@ -254,7 +254,7 @@ void InitMemory(); ObjHeader* AllocInstance(const TypeInfo* type_info, PlacementHint hint); ArrayHeader* AllocArrayInstance( const TypeInfo* type_info, PlacementHint hint, uint32_t elements); -ArrayHeader* AllocStringInstance(const char* cstring); +ArrayHeader* AllocStringInstance(const char* data, uint32_t length); #ifdef __cplusplus }