Skip to content

Commit bd8b3bb

Browse files
committed
Java lambda synthetic classes: don't modify the symtab while iterating over it
1 parent b27b828 commit bd8b3bb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,21 @@ bool java_bytecode_languaget::typecheck(
875875
// Now add synthetic classes for every invokedynamic instruction found (it
876876
// makes this easier that all interface types and their methods have been
877877
// created above):
878-
for(const auto &id_and_symbol : symbol_table)
879878
{
880-
const auto &symbol = id_and_symbol.second;
881-
const auto &id = symbol.name;
882-
if(can_cast_type<code_typet>(symbol.type) && method_bytecode.get(id))
879+
std::vector<irep_idt> methods_to_check;
880+
881+
// Careful not to add to the symtab while iterating over it:
882+
for(const auto &id_and_symbol : symbol_table)
883+
{
884+
const auto &symbol = id_and_symbol.second;
885+
const auto &id = symbol.name;
886+
if(can_cast_type<code_typet>(symbol.type) && method_bytecode.get(id))
887+
{
888+
methods_to_check.push_back(id);
889+
}
890+
}
891+
892+
for(const auto &id : methods_to_check)
883893
{
884894
create_invokedynamic_synthetic_classes(
885895
id,

0 commit comments

Comments
 (0)