Reviewers: Michael Starzinger,

Description:
Fix broken change to d8 typed arrays.

[email protected]
BUG=
TEST=


Please review this at https://chromiumcodereview.appspot.com/10441091/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/d8.cc


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"));
+      }
       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)));


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to