diff options
author | Trevor Norris <trev.norris@gmail.com> | 2013-07-05 16:31:27 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2013-07-08 09:17:22 -0700 |
commit | aa8c4a0766d4ae501433f0af5ec4d4d00300ea97 (patch) | |
tree | 904f014c66eff204c544dea6c1239042392f204c | |
parent | 58e4edaf6855025099d400ccc1ac23291b109a41 (diff) | |
download | node-aa8c4a0766d4ae501433f0af5ec4d4d00300ea97.tar.gz |
smalloc: zero size allocs may need to be free'd
Zero size allocations don't necessarily mean that data == NULL. So
instead check each value seperately and perform necessary operations.
-rw-r--r-- | src/smalloc.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/smalloc.cc b/src/smalloc.cc index dcd814156..919acf822 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -180,14 +180,15 @@ void AllocDispose(Handle<Object> obj) { char* data = static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData()); size_t length = obj->GetIndexedPropertiesExternalArrayDataLength(); - if (data == NULL || length == 0) - return; - - obj->SetIndexedPropertiesToExternalArrayData(NULL, - kExternalUnsignedByteArray, - 0); - free(data); - node_isolate->AdjustAmountOfExternalAllocatedMemory(-length); + if (data != NULL) { + obj->SetIndexedPropertiesToExternalArrayData(NULL, + kExternalUnsignedByteArray, + 0); + free(data); + } + if (length != 0) { + node_isolate->AdjustAmountOfExternalAllocatedMemory(-length); + } } |