Skip to content

Commit 2db2b53

Browse files
author
Daniel Kroening
committed
avoid direct access to exprt::op0()
This will enable protecting exprt::opX()
1 parent e12c7ee commit 2db2b53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ansi-c/expr2c.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,9 +1939,11 @@ std::string expr2ct::convert_constant(
19391939
if(src.operands().size()!=1)
19401940
return convert_norep(src, precedence);
19411941

1942-
if(src.op0().id()==ID_constant)
1942+
const auto &annotation = to_unary_expr(src).op();
1943+
1944+
if(annotation.id() == ID_constant)
19431945
{
1944-
const irep_idt &op_value=src.op0().get(ID_value);
1946+
const irep_idt &op_value = to_constant_expr(annotation).get_value();
19451947

19461948
if(op_value=="INVALID" ||
19471949
has_prefix(id2string(op_value), "INVALID-") ||
@@ -1951,7 +1953,7 @@ std::string expr2ct::convert_constant(
19511953
return convert_norep(src, precedence);
19521954
}
19531955
else
1954-
return convert_with_precedence(src.op0(), precedence);
1956+
return convert_with_precedence(annotation, precedence);
19551957
}
19561958
}
19571959
else if(type.id()==ID_string)

0 commit comments

Comments
 (0)