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

Unified Diff: src/d8.cc

Issue 10441091: Fix broken change to d8 typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index aa18afd7a2d67434046e0a8ab618ba2332122ace..28c209b87747bf97c9a617daff4e89a70e14c13a 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -338,8 +338,8 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
bool first_arg_is_array_buffer =
args[0]->IsObject() &&
- args[0]->ToObject()->GetHiddenValue(
- String::New(kArrayBufferMarkerPropName))->IsTrue();
+ !args[0]->ToObject()->GetHiddenValue(
+ String::New(kArrayBufferMarkerPropName)).IsEmpty();
// Currently, only the following constructors are supported:
// ArrayBuffer(unsigned long length)
// TypedArray(unsigned long length)
@@ -373,6 +373,10 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
} else {
byteOffset = convertToUint(args[1], &try_catch);
if (try_catch.HasCaught()) return try_catch.Exception();
+ if (byteOffset > byteLength) {
+ return ThrowException(
+ String::New("byteOffset out of bounds"));
Michael Starzinger 2012/05/30 14:25:08 That should fit into one line.
+ }
if (byteOffset % element_size != 0) {
return ThrowException(
String::New("byteOffset must be multiple of element_size"));
@@ -391,8 +395,7 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
if (byteOffset + length * element_size > byteLength) {
- return ThrowException(
- String::New("byteOffset or length out of bounds"));
+ return ThrowException(String::New("length out of bounds"));
}
byteLength = byteOffset + length * element_size;
@@ -454,7 +457,7 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
Handle<String> prop_name = String::New(kArrayBufferReferencePropName);
Handle<Object> converted_object = object->ToObject();
Local<Value> prop_value = converted_object->GetHiddenValue(prop_name);
- if (data != NULL && !prop_value->IsObject()) {
+ if (data != NULL && prop_value.IsEmpty()) {
data = reinterpret_cast<size_t*>(data) - kExternalArrayAllocationHeaderSize;
V8::AdjustAmountOfExternalAllocatedMemory(
-static_cast<int>(*reinterpret_cast<size_t*>(data)));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698