Skip to content

Commit

Permalink
codegen: fix use-after-free
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jul 28, 2017
1 parent 930a5f0 commit d2f0b3c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5695,10 +5695,15 @@ static std::unique_ptr<Module> emit_function(
}
}
if (!have_real_use) {
Instruction *use = NULL;
for (Use &U : root->uses()) {
if (use) // erase after the iterator moves on
use->eraseFromParent();
User *RU = U.getUser();
cast<Instruction>(RU)->eraseFromParent();
use = cast<Instruction>(RU);
}
if (use)
use->eraseFromParent();
root->eraseFromParent();
if (store_value)
store_value->eraseFromParent();
Expand Down

0 comments on commit d2f0b3c

Please sign in to comment.