|
@ -21,6 +21,7 @@ |
|
|
|
|
|
|
|
|
#include <stdlib.h> // calloc, etc |
|
|
#include <stdlib.h> // calloc, etc |
|
|
#include <string.h> // memmove |
|
|
#include <string.h> // memmove |
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
#include "v8_typed_array.h" |
|
|
#include "v8_typed_array.h" |
|
|
#include "node_buffer.h" |
|
|
#include "node_buffer.h" |
|
@ -722,11 +723,14 @@ class DataView { |
|
|
// TODO(deanm): All of these things should be cacheable.
|
|
|
// TODO(deanm): All of these things should be cacheable.
|
|
|
int element_size = SizeOfArrayElementForType( |
|
|
int element_size = SizeOfArrayElementForType( |
|
|
args.This()->GetIndexedPropertiesExternalArrayDataType()); |
|
|
args.This()->GetIndexedPropertiesExternalArrayDataType()); |
|
|
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() * |
|
|
assert(element_size > 0); |
|
|
element_size; |
|
|
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength(); |
|
|
|
|
|
assert(size >= 0); |
|
|
|
|
|
|
|
|
if (index + sizeof(T) > (unsigned)size) // TODO(deanm): integer overflow.
|
|
|
if (static_cast<uint64_t>(index) + sizeof(T) > |
|
|
|
|
|
static_cast<uint64_t>(size) * element_size) { |
|
|
return ThrowError("Index out of range."); |
|
|
return ThrowError("Index out of range."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); |
|
|
void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); |
|
|
return cTypeToValue<T>(getValue<T>(ptr, index, !little_endian)); |
|
|
return cTypeToValue<T>(getValue<T>(ptr, index, !little_endian)); |
|
@ -742,11 +746,14 @@ class DataView { |
|
|
// TODO(deanm): All of these things should be cacheable.
|
|
|
// TODO(deanm): All of these things should be cacheable.
|
|
|
int element_size = SizeOfArrayElementForType( |
|
|
int element_size = SizeOfArrayElementForType( |
|
|
args.This()->GetIndexedPropertiesExternalArrayDataType()); |
|
|
args.This()->GetIndexedPropertiesExternalArrayDataType()); |
|
|
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() * |
|
|
assert(element_size > 0); |
|
|
element_size; |
|
|
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength(); |
|
|
|
|
|
assert(size >= 0); |
|
|
|
|
|
|
|
|
if (index + sizeof(T) > (unsigned)size) // TODO(deanm): integer overflow.
|
|
|
if (static_cast<uint64_t>(index) + sizeof(T) > |
|
|
|
|
|
static_cast<uint64_t>(size) * element_size) { |
|
|
return ThrowError("Index out of range."); |
|
|
return ThrowError("Index out of range."); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); |
|
|
void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); |
|
|
setValue<T>(ptr, index, valueToCType<T>(args[1]), !little_endian); |
|
|
setValue<T>(ptr, index, valueToCType<T>(args[1]), !little_endian); |
|
|