summaryrefslogtreecommitdiff
path: root/src/env-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/env-inl.h')
-rw-r--r--src/env-inl.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index ffba6a2843..79c9312e66 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -759,8 +759,10 @@ inline AllocatedBuffer::AllocatedBuffer(Environment* env, uv_buf_t buf)
: env_(env), buffer_(buf) {}
inline void AllocatedBuffer::Resize(size_t len) {
- char* new_data = env_->Reallocate(buffer_.base, buffer_.len, len);
- CHECK_IMPLIES(len > 0, new_data != nullptr);
+ // The `len` check is to make sure we don't end up with `nullptr` as our base.
+ char* new_data = env_->Reallocate(buffer_.base, buffer_.len,
+ len > 0 ? len : 1);
+ CHECK_NOT_NULL(new_data);
buffer_ = uv_buf_init(new_data, len);
}