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

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


The following commit(s) were added to refs/heads/main by this push:
     new 27949b45ac GH-36949: [C++] Fix KeyColumnArray's buffers array bounds 
assertion. (#36966)
27949b45ac is described below

commit 27949b45ac71cd85293d2c2de34591c090a7f95c
Author: Francis <[email protected]>
AuthorDate: Thu Aug 10 23:09:21 2023 +0800

    GH-36949: [C++] Fix KeyColumnArray's buffers array bounds assertion. 
(#36966)
    
    
    
    ### Rationale for this change
    
    file: light_array.h
    
    The length of the buffers array is 3 (kMaxBuffers).
    
    - buffers_[kValidityBuffer]
    - buffers_[kFixedLengthBuffer]
    - buffers_[kVariableLengthBuffer]
    
    So when we do the check, the asserted index should be less than 3, not 
equal to.
    
    In addition, fix the comment line break format problem.
    
    ### What changes are included in this PR?
    
    - KeyColumnArray
    
    data and mutable_data ARROW_DCHECK.
    
    - ResizableArrayData class
    
    Comment line break formatting for mutable_data functions
    
    ### Are these changes tested?
    
    no, just change assert bound.
    
    ### Are there any user-facing changes?
    
    no
    * Closes: #36949
    
    Authored-by: light-city <[email protected]>
    Signed-off-by: Antoine Pitrou <[email protected]>
---
 cpp/src/arrow/compute/light_array.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cpp/src/arrow/compute/light_array.h 
b/cpp/src/arrow/compute/light_array.h
index d617b0aa06..3dd328c22e 100644
--- a/cpp/src/arrow/compute/light_array.h
+++ b/cpp/src/arrow/compute/light_array.h
@@ -122,12 +122,12 @@ class ARROW_EXPORT KeyColumnArray {
 
   /// \brief Return one of the underlying mutable buffers
   uint8_t* mutable_data(int i) {
-    ARROW_DCHECK(i >= 0 && i <= kMaxBuffers);
+    ARROW_DCHECK(i >= 0 && i < kMaxBuffers);
     return mutable_buffers_[i];
   }
   /// \brief Return one of the underlying read-only buffers
   const uint8_t* data(int i) const {
-    ARROW_DCHECK(i >= 0 && i <= kMaxBuffers);
+    ARROW_DCHECK(i >= 0 && i < kMaxBuffers);
     return buffers_[i];
   }
   /// \brief Return a mutable version of the offsets buffer
@@ -316,8 +316,7 @@ class ARROW_EXPORT ResizableArrayData {
   ///
   /// If i is 0 (kValidityBuffer) then this returns the validity buffer
   /// If i is 1 (kFixedLengthBuffer) then this returns the buffer used for 
values (if this
-  /// is a fixed
-  ///           length data type) or offsets (if this is a variable binary 
type)
+  /// is a fixed length data type) or offsets (if this is a variable binary 
type)
   /// If i is 2 (kVariableLengthBuffer) then this returns the buffer used for 
variable
   /// length binary data
   uint8_t* mutable_data(int i) { return buffers_[i]->mutable_data(); }

Reply via email to