You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2022/07/13 15:10:56 UTC

[arrow] branch master updated: ARROW-17041: [C++] Fix uninitialized FixedSizeBinaryScalar buffer value (#13597)

This is an automated email from the ASF dual-hosted git repository.

apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 8d949c9ecc ARROW-17041: [C++] Fix uninitialized FixedSizeBinaryScalar buffer value (#13597)
8d949c9ecc is described below

commit 8d949c9ecc43b634947c3d676a53e4d595d62bde
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Wed Jul 13 17:10:50 2022 +0200

    ARROW-17041: [C++] Fix uninitialized FixedSizeBinaryScalar buffer value (#13597)
    
    This fixes a Valgrind failure and avoids exposing past memory contents.
    
    Authored-by: Antoine Pitrou <an...@python.org>
    Signed-off-by: Antoine Pitrou <an...@python.org>
---
 cpp/src/arrow/scalar.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/scalar.cc b/cpp/src/arrow/scalar.cc
index 7f56c45b3a..21e1cdedc2 100644
--- a/cpp/src/arrow/scalar.cc
+++ b/cpp/src/arrow/scalar.cc
@@ -711,7 +711,10 @@ struct MakeNullImpl {
   Status Visit(const FixedSizeBinaryType& type) {
     ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Buffer> value,
                           AllocateBuffer(type.byte_width()));
-    out_ = std::make_shared<FixedSizeBinaryScalar>(value, type_, /*is_valid=*/false);
+    // Avoid exposing past memory contents
+    memset(value->mutable_data(), 0, value->size());
+    out_ = std::make_shared<FixedSizeBinaryScalar>(std::move(value), type_,
+                                                   /*is_valid=*/false);
     return Status::OK();
   }