Skip to content

Commit

Permalink
Fix use-after-free bug in SlidingWindow.cpp (#6527)
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson authored Jan 3, 2022
1 parent 2651402 commit f9ea2d4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SlidingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ class RollFunc : public IRMutator {
if (loops_to_rebase.count(op->name)) {
string new_name = op->name + ".rebased";
Stmt body = substitute(op->name, Variable::make(Int(32), new_name) + op->min, op->body);
result = For::make(new_name, 0, op->extent, op->for_type, op->device_api, body);
// use op->name *before* the re-assignment of result, which will clobber it
loops_to_rebase.erase(op->name);
result = For::make(new_name, 0, op->extent, op->for_type, op->device_api, body);
}
return result;
}
Expand Down

0 comments on commit f9ea2d4

Please sign in to comment.