Add missing cast in d8

Review URL: https://chromiumcodereview.appspot.com/9866035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11166 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2b3d6de2
......@@ -427,6 +427,11 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
Persistent<Object> persistent_array = Persistent<Object>::New(array);
if (data == NULL && length != 0) {
// Make sure the total size fits into a (signed) int.
static const int kMaxSize = 0x7fffffff;
if (length > (kMaxSize - sizeof(size_t)) / element_size) {
return ThrowException(String::New("Array exceeds maximum size (2G)"));
}
// Prepend the size of the allocated chunk to the data itself.
int total_size = length * element_size + sizeof(size_t);
data = malloc(total_size);
......@@ -460,7 +465,7 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
if (data != NULL && !prop_value->IsObject()) {
data = reinterpret_cast<size_t*>(data) - 1;
V8::AdjustAmountOfExternalAllocatedMemory(
-(*reinterpret_cast<size_t*>(data)));
-static_cast<int>(*reinterpret_cast<size_t*>(data)));
free(data);
}
object.Dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment