Skip to content

Commit 59b277f

Browse files
committed
Fix segmentation fault when failing to lookup parameter names
Users should not be able to trigger segmentation faults.
1 parent bf3c8ae commit 59b277f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
andNot_Bug.class
3+
--depth 1600 --java-unwind-enum-static --java-max-vla-length 48 --unwind 4 --max-nondet-string-length 100 andNot_Pass.class --function andNot_Pass.main
4+
^\*\* 1 of \d+ failed
5+
VERIFICATION FAILED
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
This somewhat bogus test (both andNot_Pass.class and andNot_Bug.class are
11+
specified on the command line) resulted in a segmentation fault when used with
12+
symex-driven-lazy-loading. Even though that's a bogus command line, user input
13+
should never trigger a segmentation fault.

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,16 +492,16 @@ static code_blockt record_pointer_parameters(
492492
for(std::size_t param_number = 0; param_number < parameters.size();
493493
param_number++)
494494
{
495-
const symbolt &p_symbol =
496-
*symbol_table.lookup(parameters[param_number].get_identifier());
495+
const symbolt *p_symbol =
496+
symbol_table.lookup(parameters[param_number].get_identifier());
497497

498-
if(!can_cast_type<pointer_typet>(p_symbol.type))
498+
if(!p_symbol || !can_cast_type<pointer_typet>(p_symbol->type))
499499
continue;
500500

501501
codet output(ID_output);
502502
output.operands().resize(2);
503503
output.op0() = address_of_exprt(index_exprt(
504-
string_constantt(p_symbol.base_name), from_integer(0, index_type())));
504+
string_constantt(p_symbol->base_name), from_integer(0, index_type())));
505505
output.op1() = arguments[param_number];
506506
output.add_source_location() = function.location;
507507

0 commit comments

Comments
 (0)