From 0f4cca68777b98e996e37354ffb8fec8d474cb46 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Wed, 31 May 2023 01:07:38 +0300 Subject: [PATCH] [K/N] Throw OutOfMemoryError when String + String overflows --- kotlin-native/runtime/src/main/cpp/KString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/runtime/src/main/cpp/KString.cpp b/kotlin-native/runtime/src/main/cpp/KString.cpp index 92f82dd0345..51813a00c63 100644 --- a/kotlin-native/runtime/src/main/cpp/KString.cpp +++ b/kotlin-native/runtime/src/main/cpp/KString.cpp @@ -178,7 +178,7 @@ OBJ_GETTER(Kotlin_String_plusImpl, KString thiz, KString other) { // Since thiz and other sizes are bounded by int32_t max value, their sum cannot exceed uint32_t max value - 1. uint32_t result_length = thiz->count_ + other->count_; if (result_length > static_cast(std::numeric_limits::max())) { - ThrowArrayIndexOutOfBoundsException(); + ThrowOutOfMemoryError(); } ArrayHeader* result = AllocArrayInstance(theStringTypeInfo, result_length, OBJ_RESULT)->array(); memcpy(