Skip to content

Commit

Permalink
Protect against invalid function label
Browse files Browse the repository at this point in the history
Check the symbol actually exists before trying to regenerate the _start
function.
  • Loading branch information
thk123 committed Sep 13, 2017
1 parent 2a3d876 commit ee5fb93
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,24 @@ int cbmc_parse_optionst::get_goto_program(

if(cmdline.isset("function"))
{
const symbolt &desired_entry_function=
symbol_table.lookup(cmdline.get_value("function"));
languaget *language=get_language_from_mode(desired_entry_function.mode);

language->regenerate_start_function(
desired_entry_function,
symbol_table,
goto_functions);
const std::string &function_id=cmdline.get_value("function");
const auto &desired_entry_function=
symbol_table.symbols.find(function_id);

if(desired_entry_function!=symbol_table.symbols.end())
{
languaget *language=get_language_from_mode(
desired_entry_function->second.mode);
language->regenerate_start_function(
desired_entry_function->second,
symbol_table,
goto_functions);
}
else
{
error() << "main symbol `" << function_id;
error() << "' not found" << messaget::eom;
}
}

if(cmdline.isset("show-symbol-table"))
Expand Down

0 comments on commit ee5fb93

Please sign in to comment.