You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2022/08/08 23:37:15 UTC

[impala] 18/27: IMPALA-11416: SlotRef::tuple_is_nullable_ uninitialised for struct children

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

stigahuang pushed a commit to branch branch-4.1.1
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 3088c37468f5867d2bb19cfbe182e6418d7655af
Author: Daniel Becker <da...@cloudera.com>
AuthorDate: Tue Jul 5 13:52:20 2022 +0200

    IMPALA-11416: SlotRef::tuple_is_nullable_ uninitialised for struct
    children
    
    In 'SlotRef::Init', 'tuple_is_nullable_' is only assigned a value if the
    'SlotRef' is not within a struct:
    
      ```
      if (!slot_desc_->parent()->isTupleOfStructSlot()) {
        tuple_is_nullable_ = row_desc.TupleIsNullable(tuple_idx_);
      }
      ```
    
    Otherwise 'tuple_is_nullable_' remains uninitialised, leading to
    undefined behaviour when it is read.
    
    After this commit, 'tuple_is_nullable_' is set to false within structs.
    
    Change-Id: I67517502ebc8f9bec52cb61d9922523cc4a56c4a
    Reviewed-on: http://gerrit.cloudera.org:8080/18702
    Reviewed-by: Gabor Kaszab <ga...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/exprs/slot-ref.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/be/src/exprs/slot-ref.cc b/be/src/exprs/slot-ref.cc
index 55b1137b2..32d4e254c 100644
--- a/be/src/exprs/slot-ref.cc
+++ b/be/src/exprs/slot-ref.cc
@@ -99,9 +99,8 @@ Status SlotRef::Init(
       return Status(error);
     }
     DCHECK(tuple_idx_ != RowDescriptor::INVALID_IDX);
-    if (!slot_desc_->parent()->isTupleOfStructSlot()) {
-      tuple_is_nullable_ = row_desc.TupleIsNullable(tuple_idx_);
-    }
+    tuple_is_nullable_ = slot_desc_->parent()->isTupleOfStructSlot() ?
+        false : row_desc.TupleIsNullable(tuple_idx_);
     slot_offset_ = slot_desc_->tuple_offset();
     null_indicator_offset_ = slot_desc_->null_indicator_offset();
   }