Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 5534db557ce53faee9c85aed9681749804354619..327114898078769f44d057252b850acc799ac182 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -5020,11 +5020,12 @@ static int CopyCachedAsciiCharsToArray(const char* chars, |
// For example, "foo" => ["f", "o", "o"]. |
static MaybeObject* Runtime_StringToArray(Arguments args) { |
HandleScope scope; |
- ASSERT(args.length() == 1); |
+ ASSERT(args.length() == 2); |
CONVERT_ARG_CHECKED(String, s, 0); |
+ CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
s->TryFlatten(); |
- const int length = s->length(); |
+ const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); |
Handle<FixedArray> elements; |
if (s->IsFlat() && s->IsAsciiRepresentation()) { |