Skip to content

Commit c503366

Browse files
Merge pull request #856 from cristina-david/bugfix/uninitialised-exceptional-value
Always initialise the exceptional return variable of the entry function
2 parents 2dc8cf3 + 1e9123f commit c503366

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/goto-programs/remove_exceptions.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ void remove_exceptionst::add_exceptional_returns(
9090
if(goto_program.empty())
9191
return;
9292

93+
// the entry function has already been added to the symbol table
94+
// if you find it, initialise it
95+
if(symbol_table.has_symbol(id2string(function_id)+EXC_SUFFIX))
96+
{
97+
const symbolt &symbol=
98+
symbol_table.lookup(id2string(function_id)+EXC_SUFFIX);
99+
symbol_exprt lhs_expr_null=symbol.symbol_expr();
100+
null_pointer_exprt rhs_expr_null((pointer_typet(empty_typet())));
101+
goto_programt::targett t_null=
102+
goto_program.insert_before(goto_program.instructions.begin());
103+
t_null->make_assignment();
104+
t_null->source_location=
105+
goto_program.instructions.begin()->source_location;
106+
t_null->code=code_assignt(
107+
lhs_expr_null,
108+
rhs_expr_null);
109+
t_null->function=function_id;
110+
return;
111+
}
112+
93113
// We generate an exceptional return value for any function that has
94114
// a throw or a function call. This can be improved by only considering
95115
// function calls that may escape exceptions. However, this will

0 commit comments

Comments
 (0)