smalloc: fix bad assert for zero length data

If the data length passed to smalloc.alloc() the array_length will be
zero, causing an overflow check to fail. This prevents that from
happening.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
Trevor Norris 2015-01-05 02:20:31 -08:00
parent b636ba8186
commit 372a2f56be

View File

@ -132,7 +132,7 @@ void CallbackInfo::WeakCallback(Isolate* isolate, Local<Object> object) {
object->GetIndexedPropertiesExternalArrayDataType();
size_t array_size = ExternalArraySize(array_type);
CHECK_GT(array_size, 0);
if (array_size > 1) {
if (array_size > 1 && array_data != NULL) {
CHECK_GT(array_length * array_size, array_length); // Overflow check.
array_length *= array_size;
}