Skip to content

Commit

Permalink
Fix heap-use-after-free error in find_best_fit() (Fixes #8482) (#8483)
Browse files Browse the repository at this point in the history
* Fix heap-use-after-free error in find_best_fit() (Fixes #8482)

* Update FuseGPUThreadLoops.cpp
  • Loading branch information
steven-johnson authored Nov 20, 2024
1 parent ff12d4a commit f566881
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FuseGPUThreadLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ class ExtractSharedAndHeapAllocations : public IRMutator {
const auto &candidate_group = mem_allocs[free_spaces[i]];
Expr size = alloc_size * alloc.type.bytes();
Expr dist = candidate_group.max_size * candidate_group.widest_type.bytes() - size;
const int64_t *current_diff = as_const_int(simplify(dist));
dist = simplify(dist);
const int64_t *current_diff = as_const_int(dist);
internal_assert(current_diff != nullptr);
int64_t abs_diff = std::abs(*current_diff);
if ((free_idx == -1) || (abs_diff < diff)) {
Expand Down

0 comments on commit f566881

Please sign in to comment.