mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 16:40:56 +00:00
- fixed: The conditional operator could clobber a local variable if it was the result of the true expression.
This commit is contained in:
parent
1a16f664e4
commit
e7cd5ec2bb
1 changed files with 12 additions and 2 deletions
|
@ -208,6 +208,10 @@ ExpEmit::ExpEmit(VMFunctionBuilder *build, int type, int count)
|
||||||
|
|
||||||
void ExpEmit::Free(VMFunctionBuilder *build)
|
void ExpEmit::Free(VMFunctionBuilder *build)
|
||||||
{
|
{
|
||||||
|
if (RegType == REGT_INT && RegNum == 0)
|
||||||
|
{
|
||||||
|
int a = 0;
|
||||||
|
}
|
||||||
if (!Fixed && !Konst && RegType <= REGT_TYPE)
|
if (!Fixed && !Konst && RegType <= REGT_TYPE)
|
||||||
{
|
{
|
||||||
build->Registers[RegType].Return(RegNum, RegCount);
|
build->Registers[RegType].Return(RegNum, RegCount);
|
||||||
|
@ -4584,8 +4588,14 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Use the register returned by the true condition as the
|
// Use the register returned by the true condition as the
|
||||||
// target for the false condition.
|
// target for the false condition, if temporary.
|
||||||
out = trueop;
|
// If this is a local variable we need another register for the result.
|
||||||
|
if (trueop.Fixed)
|
||||||
|
{
|
||||||
|
out = ExpEmit(build, trueop.RegType);
|
||||||
|
build->Emit(truex->ValueType->GetMoveOp(), out.RegNum, trueop.RegNum, 0);
|
||||||
|
}
|
||||||
|
else out = trueop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make sure to skip the false path.
|
// Make sure to skip the false path.
|
||||||
|
|
Loading…
Reference in a new issue