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

Unified Diff: runtime/lib/string.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 | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc
index 111b70c28035a39e50e6e3f6fa22c6cf475550e9..915e57593a6ff2fa92a63db2fcff7d142ed8cfc0 100644
--- a/runtime/lib/string.cc
+++ b/runtime/lib/string.cc
@@ -157,27 +157,25 @@ DEFINE_NATIVE_ENTRY(OneByteString_allocate, 1) {
DEFINE_NATIVE_ENTRY(OneByteString_allocateFromOneByteList, 1) {
Instance& list = Instance::CheckedHandle(arguments->NativeArgAt(0));
- uint8_t* data = NULL;
- intptr_t length = 0;
if (list.IsTypedData()) {
const TypedData& array = TypedData::Cast(list);
- length = array.LengthInBytes();
- data = reinterpret_cast<uint8_t*>(array.DataAddr(0));
+ intptr_t length = array.LengthInBytes();
+ return OneByteString::New(array, 0, length, Heap::kNew);
} else if (list.IsExternalTypedData()) {
const ExternalTypedData& array = ExternalTypedData::Cast(list);
- length = array.LengthInBytes();
- data = reinterpret_cast<uint8_t*>(array.DataAddr(0));
+ intptr_t length = array.LengthInBytes();
+ return OneByteString::New(array, 0, length, Heap::kNew);
} else if (RawObject::IsTypedDataViewClassId(list.GetClassId())) {
const Instance& view = Instance::Cast(list);
- length = Smi::Value(TypedDataView::Length(view));
+ intptr_t length = Smi::Value(TypedDataView::Length(view));
const Instance& data_obj = Instance::Handle(TypedDataView::Data(view));
intptr_t data_offset = Smi::Value(TypedDataView::OffsetInBytes(view));
if (data_obj.IsTypedData()) {
const TypedData& array = TypedData::Cast(data_obj);
- data = reinterpret_cast<uint8_t*>(array.DataAddr(data_offset));
+ return OneByteString::New(array, data_offset, length, Heap::kNew);
} else if (data_obj.IsExternalTypedData()) {
const ExternalTypedData& array = ExternalTypedData::Cast(data_obj);
- data = reinterpret_cast<uint8_t*>(array.DataAddr(data_offset));
+ return OneByteString::New(array, data_offset, length, Heap::kNew);
} else {
UNREACHABLE();
}
@@ -202,7 +200,7 @@ DEFINE_NATIVE_ENTRY(OneByteString_allocateFromOneByteList, 1) {
} else {
UNREACHABLE();
}
- return OneByteString::New(data, length, Heap::kNew);
+ return Object::null();
Ivan Posva 2014/03/24 18:30:43 Please put an UNREACHABLE here and drop the others
Anders Johnsen 2014/03/24 18:48:46 Done, partially. I need to return something after
}
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698