diff --git a/src/api/environment.cc b/src/api/environment.cc index a87f591e4edf57..70228b77d8860b 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -139,7 +139,11 @@ void DebuggingArrayBufferAllocator::UnregisterPointerInternal(void* data, if (data == nullptr) return; auto it = allocations_.find(data); CHECK_NE(it, allocations_.end()); - CHECK_EQ(it->second, size); + if (size > 0) { + // We allow allocations with size 1 for 0-length buffers to avoid having + // to deal with nullptr values. + CHECK_EQ(it->second, size); + } allocations_.erase(it); } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 19d2de96b1c057..58175a8fd5f615 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -420,7 +420,7 @@ MaybeLocal New(Environment* env, } if (uses_malloc) { - if (env->isolate_data()->uses_node_allocator()) { + if (!env->isolate_data()->uses_node_allocator()) { // We don't know for sure that the allocator is malloc()-based, so we need // to fall back to the FreeCallback variant. auto free_callback = [](char* data, void* hint) { free(data); };