mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Fix heap-use-after-free bug in expandSDiv when the operands are
constants, as discovered by ASAN. Patch by Mehdi Amini! llvm-svn: 221401
This commit is contained in:
parent
aa5c69a514
commit
f1932a5b9a
@ -398,11 +398,13 @@ bool llvm::expandRemainder(BinaryOperator *Rem) {
|
|||||||
Rem->dropAllReferences();
|
Rem->dropAllReferences();
|
||||||
Rem->eraseFromParent();
|
Rem->eraseFromParent();
|
||||||
|
|
||||||
// If we didn't actually generate a udiv instruction, we're done
|
// If we didn't actually generate an urem instruction, we're done
|
||||||
BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint());
|
// This happens for example if the input were constant. In this case the
|
||||||
if (!BO || BO->getOpcode() != Instruction::URem)
|
// Builder insertion point was unchanged
|
||||||
|
if (Rem == Builder.GetInsertPoint())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint());
|
||||||
Rem = BO;
|
Rem = BO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,11 +458,13 @@ bool llvm::expandDivision(BinaryOperator *Div) {
|
|||||||
Div->dropAllReferences();
|
Div->dropAllReferences();
|
||||||
Div->eraseFromParent();
|
Div->eraseFromParent();
|
||||||
|
|
||||||
// If we didn't actually generate a udiv instruction, we're done
|
// If we didn't actually generate an udiv instruction, we're done
|
||||||
BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint());
|
// This happens for example if the input were constant. In this case the
|
||||||
if (!BO || BO->getOpcode() != Instruction::UDiv)
|
// Builder insertion point was unchanged
|
||||||
|
if (Div == Builder.GetInsertPoint())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint());
|
||||||
Div = BO;
|
Div = BO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user