Index: src/runtime/runtime-strings.cc |
diff --git a/src/runtime/runtime-strings.cc b/src/runtime/runtime-strings.cc |
index c1f14adb277cd18a8e03024aab47246e8d34a824..78b4ed227bd75776659a66410f3e37efc5687af1 100644 |
--- a/src/runtime/runtime-strings.cc |
+++ b/src/runtime/runtime-strings.cc |
@@ -298,9 +298,11 @@ RUNTIME_FUNCTION(Runtime_SubString) { |
start = FastD2IChecked(from_number); |
end = FastD2IChecked(to_number); |
} |
- RUNTIME_ASSERT(end >= start); |
- RUNTIME_ASSERT(start >= 0); |
- RUNTIME_ASSERT(end <= string->length()); |
+ // The following condition is intentionally robust because the SubStringStub |
+ // delegates here and we test this in cctest/test-strings/RobustSubStringStub. |
+ if (end < start || start < 0 || end > string->length()) { |
+ return isolate->ThrowIllegalOperation(); |
+ } |
isolate->counters()->sub_string_runtime()->Increment(); |
return *isolate->factory()->NewSubString(string, start, end); |