Skip to content

Commit

Permalink
br_table: avoid an integer underflow to suppress ubsan
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Apr 24, 2023
1 parent 29cfd94 commit 4a3b830
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/insn_impl_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,13 @@ INSN_IMPL(br_table)
l = vec_count;
}
uint32_t idx;
do {
while (true) {
idx = read_leb_u32_nocheck(&p);
} while (l-- > 0);
if (l == 0) {
break;
}
l--;
}
ectx->event_u.branch.index = idx;
ectx->event_u.branch.goto_else = false;
ectx->event = EXEC_EVENT_BRANCH;
Expand Down

0 comments on commit 4a3b830

Please sign in to comment.