Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
smalloc: fix bad assert for zero length data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
trevnorris committed Jan 5, 2015
1 parent b636ba8 commit 372a2f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/smalloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 372a2f5

Please sign in to comment.