diff --git a/src/smalloc.cc b/src/smalloc.cc index c4c1663c239..8100fbf81ad 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -301,11 +301,14 @@ void AllocDispose(const FunctionCallbackInfo& args) { void AllocDispose(Handle obj) { HandleScope scope(node_isolate); - if (using_alloc_cb && obj->Has(smalloc_sym)) { - Local ext = obj->GetHiddenValue(smalloc_sym).As(); - CallbackInfo* cb_info = static_cast(ext->Value()); - TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info); - return; + if (using_alloc_cb) { + Local ext_v = obj->GetHiddenValue(smalloc_sym); + if (ext_v->IsExternal()) { + Local ext = ext_v.As(); + CallbackInfo* cb_info = static_cast(ext->Value()); + TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info); + return; + } } char* data = static_cast(obj->GetIndexedPropertiesExternalArrayData());