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

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


The following commit(s) were added to refs/heads/main by this push:
     new 5e12a5cc97 [Fix][Relax] Fix potential out-of-bounds access in 
`TupleRewriterNode` (#18120)
5e12a5cc97 is described below

commit 5e12a5cc97793a4bdbbe8cc213e82b80e704a3c9
Author: Phoslight <[email protected]>
AuthorDate: Sat Jul 19 04:30:09 2025 -0700

    [Fix][Relax] Fix potential out-of-bounds access in `TupleRewriterNode` 
(#18120)
    
    * Root cause
    
    * Update
---
 src/relax/ir/dataflow_expr_rewriter.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/relax/ir/dataflow_expr_rewriter.cc 
b/src/relax/ir/dataflow_expr_rewriter.cc
index 8074790003..123b18d81c 100644
--- a/src/relax/ir/dataflow_expr_rewriter.cc
+++ b/src/relax/ir/dataflow_expr_rewriter.cc
@@ -387,8 +387,9 @@ Map<Var, Expr> 
TupleRewriterNode::GenerateVariableRewrites(const Array<Binding>&
         for (size_t j_rev = 1; j_rev < info_vec.size(); j_rev++) {
           size_t j = info_vec.size() - j_rev - 1;
           if (info_vec[j].matches[i] && !info_vec[j].used &&
-              std::all_of(indices.begin() + (j + 1), indices.end(),
-                          [j](size_t prev_binding_index) { return j != 
prev_binding_index; })) {
+              (j + 1 >= indices.size() ||
+               std::all_of(indices.begin() + (j + 1), indices.end(),
+                           [j](size_t prev_binding_index) { return j != 
prev_binding_index; }))) {
             return j;
           }
         }

Reply via email to