Browse Source

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.
Trevor Norris 12 years ago
parent
commit
aa8c4a0766
  1. 17
      src/smalloc.cc

17
src/smalloc.cc

@ -180,14 +180,15 @@ void AllocDispose(Handle<Object> obj) {
char* data = static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData()); char* data = static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData());
size_t length = obj->GetIndexedPropertiesExternalArrayDataLength(); size_t length = obj->GetIndexedPropertiesExternalArrayDataLength();
if (data == NULL || length == 0) if (data != NULL) {
return; obj->SetIndexedPropertiesToExternalArrayData(NULL,
kExternalUnsignedByteArray,
obj->SetIndexedPropertiesToExternalArrayData(NULL, 0);
kExternalUnsignedByteArray, free(data);
0); }
free(data); if (length != 0) {
node_isolate->AdjustAmountOfExternalAllocatedMemory(-length); node_isolate->AdjustAmountOfExternalAllocatedMemory(-length);
}
} }

Loading…
Cancel
Save