Skip to content

Commit 5e12a5c

Browse files
authored
[Fix][Relax] Fix potential out-of-bounds access in TupleRewriterNode (#18120)
* Root cause * Update
1 parent e05064f commit 5e12a5c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/relax/ir/dataflow_expr_rewriter.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,9 @@ Map<Var, Expr> TupleRewriterNode::GenerateVariableRewrites(const Array<Binding>&
387387
for (size_t j_rev = 1; j_rev < info_vec.size(); j_rev++) {
388388
size_t j = info_vec.size() - j_rev - 1;
389389
if (info_vec[j].matches[i] && !info_vec[j].used &&
390-
std::all_of(indices.begin() + (j + 1), indices.end(),
391-
[j](size_t prev_binding_index) { return j != prev_binding_index; })) {
390+
(j + 1 >= indices.size() ||
391+
std::all_of(indices.begin() + (j + 1), indices.end(),
392+
[j](size_t prev_binding_index) { return j != prev_binding_index; }))) {
392393
return j;
393394
}
394395
}

0 commit comments

Comments
 (0)