Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Unified Diff: runtime/lib/string.cc

Issue 8455004: Fix crashes in String natives. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 1173)
+++ runtime/lib/string.cc (working copy)
@@ -85,8 +85,10 @@
}
return str.CharAt(index);
} else {
- // TODO(srdjan): Bigint index not supported.
- UNIMPLEMENTED();
+ // An index larger than Smi is always illegal.
+ GrowableArray<const Object*> arguments;
+ arguments.Add(&index);
+ Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments);
return 0;
}
}
@@ -159,6 +161,20 @@
DEFINE_NATIVE_ENTRY(Strings_concatAll, 1) {
const Array& strings = Array::CheckedHandle(arguments->At(0));
ASSERT(!strings.IsNull());
+ // Check that the array contains strings.
+ Instance& elem = Instance::Handle();
+ for (intptr_t i = 0; i < strings.Length(); i++) {
+ elem ^= strings.At(i);
+ if (elem.IsNull()) {
+ GrowableArray<const Object*> args;
+ Exceptions::ThrowByType(Exceptions::kNullPointer, args);
+ }
+ if (!elem.IsString()) {
+ GrowableArray<const Object*> args;
+ args.Add(&elem);
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ }
+ }
const String& result = String::Handle(String::ConcatAll(strings));
arguments->SetReturn(result);
}
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698