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

Unified Diff: runtime/vm/object.cc

Issue 16783003: Fix issue 11214 avoid length overflow in String::ConcatAll (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months 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/language/string_overflow.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 23830)
+++ runtime/vm/object.cc (working copy)
@@ -11713,7 +11713,15 @@
intptr_t char_size = kOneByteChar;
for (intptr_t i = 0; i < strings_len; i++) {
str ^= strings.At(i);
- result_len += str.Length();
+ intptr_t str_len = str.Length();
+ if ((kMaxElements - result_len) < str_len) {
+ Isolate* isolate = Isolate::Current();
+ const Instance& exception =
+ Instance::Handle(isolate->object_store()->out_of_memory());
+ Exceptions::Throw(exception);
+ UNREACHABLE();
+ }
+ result_len += str_len;
char_size = Utils::Maximum(char_size, str.CharSize());
}
if (char_size == kOneByteChar) {
@@ -12187,6 +12195,7 @@
str ^= strings.At(i);
intptr_t str_len = str.Length();
String::Copy(result, pos, str, 0, str_len);
+ ASSERT((kMaxElements - pos) >= str_len);
pos += str_len;
}
return OneByteString::raw(result);
@@ -12350,6 +12359,7 @@
str ^= strings.At(i);
intptr_t str_len = str.Length();
String::Copy(result, pos, str, 0, str_len);
+ ASSERT((kMaxElements - pos) >= str_len);
pos += str_len;
}
return TwoByteString::raw(result);
« no previous file with comments | « no previous file | tests/language/string_overflow.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698