tcg/optimize: fix uninitialized variable
PATCH 1/1 tcg/optimize: fix uninitialized variable
The variables uext_opc and sext_opc are used without initialization if TCG_TARGET_extract_i{32,64}_valid returns false. The result, depending on the compiler, might be the generation of extract and sextract opcodes with invalid offset and count, or just random data in the TCG opcode stream.
--- tcg/optimize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tcg/optimize.c +2 -1
@@ -2102,7 +2102,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op)static void fold_setcond_tst_pow2 (OptContext *ctx,TCGOp *op,bool neg) { -TCGOpcode and_opc, sub_opc, xor_opc, neg_opc, shr_opc, uext_opc, sext_opc; +TCGOpcode and_opc, sub_opc, xor_opc, neg_opc, shr_opc; +TCGOpcode uext_opc =0 , sext_opc =0 ;TCGCond cond = op->args[3 ];TCGArg ret, src1, src2;TCGOp *op2;
Signature · 1 line
2.43.2
Quoted 3 lines · Paolo Bonzini
The variables
uext_opcandsext_opcare used without initialization if TCG_TARGET_extract_i{32,64}_valid returns false. The result, depending on the compiler, might be the generation of extract and sextract opcodes
Shouldn't compilers bark?
Quoted 9 lines
with invalid offset and count, or just random data in the TCG opcode stream.
Fixes ceb9ee06b71 ("tcg/optimize: Handle TCG_COND_TST{EQ,NE}", 2024-02-03)Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- tcg/optimize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Paolo Bonzini
The variables
uext_opcandsext_opcare used without initialization if TCG_TARGET_extract_i{32,64}_valid returns false. The result, depending on the compiler, might be the generation of extract and sextract opcodesShouldn't compilers bark?
I expected that too...
Paolo
Quoted 12 lines
Quoted 9 lines
with invalid offset and count, or just random data in the TCG opcode stream.
Fixes ceb9ee06b71 ("tcg/optimize: Handle TCG_COND_TST{EQ,NE}", 2024-02-03)Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- tcg/optimize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Richard Henderson
Reviewed-byQuoted 11 lines · Paolo Bonzini
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Paolo Bonzini
The variables
uext_opcandsext_opcare used without initialization if TCG_TARGET_extract_i{32,64}_valid returns false. The result, depending on the compiler, might be the generation of extract and sextract opcodesShouldn't compilers bark?
I expected that too...
Weird. Anyhoo,
r~
Richard Henderson
AppliedQuoted 9 lines · Richard Henderson
Quoted 8 lines · Paolo Bonzini
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Paolo Bonzini
The variables
uext_opcandsext_opcare used without initialization if TCG_TARGET_extract_i{32,64}_valid returns false. The result, depending on the compiler, might be the generation of extract and sextract opcodes
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Shouldn't compilers bark?
I expected that too...
Weird. Anyhoo,
Reviewed-by Richard Henderson <[email protected]>
Queued, thanks.
r~