src: fix check for accepting Buffers into Node’s allocator · nodejs/node@427fce7 (original) (raw)
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -139,7 +139,11 @@ void DebuggingArrayBufferAllocator::UnregisterPointerInternal(void* data, | ||
139 | 139 | if (data == nullptr) return; |
140 | 140 | auto it = allocations_.find(data); |
141 | 141 | CHECK_NE(it, allocations_.end()); |
142 | -CHECK_EQ(it->second, size); | |
142 | +if (size > 0) { | |
143 | +// We allow allocations with size 1 for 0-length buffers to avoid having | |
144 | +// to deal with nullptr values. | |
145 | +CHECK_EQ(it->second, size); | |
146 | + } | |
143 | 147 | allocations_.erase(it); |
144 | 148 | } |
145 | 149 |