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

Unified Diff: runtime/vm/object.cc

Issue 209003009: Fix memory-issue String::fromCharCodes, where a GC could invalidate an address. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b6921462f6da1e22c5fc1f74721b5999db584c52..fbab42f1df58358c173e3a0d147573bccdc95db5 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -16293,6 +16293,38 @@ RawOneByteString* OneByteString::New(const String& other_one_byte_string,
}
+RawOneByteString* OneByteString::New(const TypedData& other_typed_data,
+ intptr_t other_start_index,
+ intptr_t other_len,
+ Heap::Space space) {
+ const String& result = String::Handle(OneByteString::New(other_len, space));
+ ASSERT(other_typed_data.ElementSizeInBytes() == 1);
+ if (other_len > 0) {
+ NoGCScope no_gc;
+ memmove(OneByteString::CharAddr(result, 0),
+ other_typed_data.DataAddr(other_start_index),
+ other_len);
+ }
+ return OneByteString::raw(result);
+}
+
+
+RawOneByteString* OneByteString::New(const ExternalTypedData& other_typed_data,
+ intptr_t other_start_index,
+ intptr_t other_len,
+ Heap::Space space) {
+ const String& result = String::Handle(OneByteString::New(other_len, space));
+ ASSERT(other_typed_data.ElementSizeInBytes() == 1);
+ if (other_len > 0) {
+ NoGCScope no_gc;
+ memmove(OneByteString::CharAddr(result, 0),
+ other_typed_data.DataAddr(other_start_index),
+ other_len);
+ }
+ return OneByteString::raw(result);
+}
+
+
RawOneByteString* OneByteString::Concat(const String& str1,
const String& str2,
Heap::Space space) {
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698