Skip to content

Commit 581fbee

Browse files
Do not call assign_from_json if not in symbol_table
The assign_from_json will fail with an invariant failure if it is called on a method name that does not exist in the symbol table so we should be carreful when calling it.
1 parent 7520078 commit 581fbee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ code_blockt get_user_specified_clinit_body(
777777
std::unordered_map<std::string, object_creation_referencet> &references)
778778
{
779779
jsont json;
780+
const irep_idt real_clinit_name = clinit_function_name(class_id);
780781
if(
781782
!static_values_file.empty() &&
782783
!parse_json(static_values_file, message_handler, json) && json.is_object())
@@ -808,13 +809,15 @@ code_blockt get_user_specified_clinit_body(
808809
}
809810
}
810811
}
812+
if(symbol_table.lookup(real_clinit_name) == nullptr)
813+
return code_blockt{};
811814
code_blockt body;
812815
for(const auto &value_pair : static_field_values)
813816
{
814817
assign_from_json(
815818
value_pair.first,
816819
value_pair.second,
817-
clinit_function_name(class_id),
820+
real_clinit_name,
818821
body,
819822
symbol_table,
820823
needed_lazy_methods,
@@ -825,7 +828,6 @@ code_blockt get_user_specified_clinit_body(
825828
}
826829
}
827830
}
828-
const irep_idt &real_clinit_name = clinit_function_name(class_id);
829831
if(const auto clinit_func = symbol_table.lookup(real_clinit_name))
830832
return code_blockt{{code_function_callt{clinit_func->symbol_expr()}}};
831833
return code_blockt{};

0 commit comments

Comments
 (0)