Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 96d07a859b296b5223d7355f56d1fbb591535b17..781ac0c7c3e0092893331e4496416f837015f454 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -3487,8 +3487,10 @@ static MaybeObject* Runtime_KeyedGetProperty(Arguments args) { |
HandleScope scope; |
Handle<String> str = args.at<String>(0); |
int index = Smi::cast(args[1])->value(); |
- Handle<Object> result = GetCharAt(str, index); |
- return *result; |
+ if (index >= 0 && index < str->length()) { |
+ Handle<Object> result = GetCharAt(str, index); |
+ return *result; |
+ } |
} |
// Fall back to GetObjectProperty. |