diff --git a/runtime/src/main/cpp/Arrays.cpp b/runtime/src/main/cpp/Arrays.cpp index 523c15ef20f..e244b7d20f1 100644 --- a/runtime/src/main/cpp/Arrays.cpp +++ b/runtime/src/main/cpp/Arrays.cpp @@ -38,8 +38,8 @@ inline void copyImpl(KConstRef thiz, KInt fromIndex, const ArrayHeader* array = thiz->array(); ArrayHeader* destinationArray = destination->array(); if (count < 0 || - fromIndex < 0 || count > array->count_ - fromIndex || - toIndex < 0 || count > destinationArray->count_ - toIndex) { + fromIndex < 0 || static_cast(count) + fromIndex > array->count_ || + toIndex < 0 || static_cast(count) + toIndex > destinationArray->count_) { ThrowArrayIndexOutOfBoundsException(); } mutabilityCheck(destination); @@ -96,8 +96,8 @@ void Kotlin_Array_copyImpl(KConstRef thiz, KInt fromIndex, const ArrayHeader* array = thiz->array(); ArrayHeader* destinationArray = destination->array(); if (count < 0 || - fromIndex < 0 || count > array->count_ - fromIndex || - toIndex < 0 || count > destinationArray->count_ - toIndex) { + fromIndex < 0 || static_cast(count) + fromIndex > array->count_ || + toIndex < 0 || static_cast(count)+ toIndex > destinationArray->count_) { ThrowArrayIndexOutOfBoundsException(); } mutabilityCheck(destination);