Skip to content

Commit dae6c09

Browse files
authored
Merge pull request #6682 from tautschnig/bugfixes/codeql-wrong-index-type
Java front-end: fix vector index type in populate_live_range_holes
2 parents 98c23f5 + 1d5c4b1 commit dae6c09

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jbmc/src/java_bytecode/java_local_variable_table.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,18 +513,18 @@ static void populate_live_range_holes(
513513
merge_vars.begin(), merge_vars.end());
514514
std::sort(sorted_by_startpc.begin(), sorted_by_startpc.end(), lt_startpc);
515515

516+
PRECONDITION(!sorted_by_startpc.empty());
516517
maybe_add_hole(
517518
merge_into,
518519
expanded_live_range_start,
519520
sorted_by_startpc[0]->var.start_pc);
520-
for(java_bytecode_convert_methodt::method_offsett idx = 0;
521-
idx < sorted_by_startpc.size() - 1;
522-
++idx)
521+
for(auto it = std::next(sorted_by_startpc.begin());
522+
it != sorted_by_startpc.end();
523+
++it)
523524
{
525+
auto &local_var = (*std::prev(it))->var;
524526
maybe_add_hole(
525-
merge_into,
526-
sorted_by_startpc[idx]->var.start_pc+sorted_by_startpc[idx]->var.length,
527-
sorted_by_startpc[idx+1]->var.start_pc);
527+
merge_into, local_var.start_pc + local_var.length, (*it)->var.start_pc);
528528
}
529529
}
530530

0 commit comments

Comments
 (0)