diff --git a/src/env-inl.h b/src/env-inl.h index 71660a035c8ea7..7836bd2cbc5d60 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -1029,7 +1029,10 @@ inline AllocatedBuffer::~AllocatedBuffer() { inline void AllocatedBuffer::clear() { uv_buf_t buf = release(); - env_->Free(buf.base, buf.len); + if (buf.base != nullptr) { + CHECK_NOT_NULL(env_); + env_->Free(buf.base, buf.len); + } } // It's a bit awkward to define this Buffer::New() overload here, but it