From 10a897f987b63fb3c5565b0d86b705641bc0292a Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Sun, 19 Mar 2017 19:33:43 -0700 Subject: [PATCH] Initialize memory obtained by BufferBuilder to zero --- cpp/src/arrow/buffer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h index 1647e8601f48..70c16a2dafc8 100644 --- a/cpp/src/arrow/buffer.h +++ b/cpp/src/arrow/buffer.h @@ -170,9 +170,13 @@ class ARROW_EXPORT BufferBuilder { // Resize(0) is a no-op if (elements == 0) { return Status::OK(); } if (capacity_ == 0) { buffer_ = std::make_shared(pool_); } + int64_t old_capacity = capacity_; RETURN_NOT_OK(buffer_->Resize(elements)); capacity_ = buffer_->capacity(); data_ = buffer_->mutable_data(); + if (capacity_ > old_capacity) { + memset(data_ + old_capacity, 0, capacity_ - old_capacity); + } return Status::OK(); }