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. 7
      src/smalloc.cc

7
src/smalloc.cc

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

Loading…
Cancel
Save