msridhar78 commented on code in PR #56696:
URL: https://github.com/apache/doris/pull/56696#discussion_r2404976241


##########
be/src/vec/columns/column_vector.cpp:
##########
@@ -279,19 +279,35 @@ void ColumnVector<T>::insert_range_from(const IColumn& 
src, size_t start, size_t
 template <PrimitiveType T>
 void ColumnVector<T>::insert_indices_from(const IColumn& src, const uint32_t* 
indices_begin,
                                           const uint32_t* indices_end) {
+    const auto& src_concrete = static_cast<const ColumnVector<T>&>(src);
+    size_t src_size = src_concrete.size();
+    if (indices_begin == nullptr || indices_end == nullptr || indices_begin > 
indices_end) {
+        throw Exception(ErrorCode::INTERNAL_ERROR,
+                        "Invalid index range: begin={}, end={}",
+                        static_cast<const void*>(indices_begin),
+                        static_cast<const void*>(indices_end));
+    }
+                                            
     auto origin_size = size();
     auto new_size = indices_end - indices_begin;
+    if (new_size == 0) {
+        return;
+    }
     data.resize(origin_size + new_size);
 
     auto copy = [](const value_type* __restrict src, value_type* __restrict 
dest,
-                   const uint32_t* __restrict begin, const uint32_t* 
__restrict end) {
+                   const uint32_t* __restrict begin, const uint32_t* 
__restrict end, size_t src_size) {
         for (const auto* it = begin; it != end; ++it) {
+            if (*it >= src_size) {
+                throw Exception(ErrorCode::INTERNAL_ERROR,

Review Comment:
   This check is made to ensure that each index *it is less than src_size 
before accessing src[*it] - the UT attached simulates this error condition and 
hence this check..please let me know your thoughts



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to