summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/api/environment.cc6
-rw-r--r--src/node_buffer.cc2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc
index a87f591e4e..70228b77d8 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 19d2de96b1..58175a8fd5 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -420,7 +420,7 @@ MaybeLocal<Object> 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); };