Skip to content

Commit

Permalink
Fix negative 2-byte range switch check.
Browse files Browse the repository at this point in the history
  • Loading branch information
dworkin committed Aug 21, 2024
1 parent 47470d0 commit 85f8d80
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,12 +1589,10 @@ unsigned short Frame::switchRange(char *pc)
while (l < h) {
m = (l + h) >> 1;
p = pc + 4 * m;
num = FETCH1S(p);
if (sp->number < num) {
if (sp->number < FETCH1S(p)) {
h = m; /* search in lower half */
} else {
num = FETCH1S(p);
if (sp->number <= num) {
if (sp->number <= FETCH1S(p)) {
return FETCH2U(p, l);
}
l = m + 1; /* search in upper half */
Expand All @@ -1606,12 +1604,10 @@ unsigned short Frame::switchRange(char *pc)
while (l < h) {
m = (l + h) >> 1;
p = pc + 6 * m;
FETCH2S(p, num);
if (sp->number < num) {
if (sp->number < FETCH2S(p, num)) {
h = m; /* search in lower half */
} else {
FETCH2S(p, num);
if (sp->number <= num) {
if (sp->number <= FETCH2S(p, num)) {
return FETCH2U(p, l);
}
l = m + 1; /* search in upper half */
Expand Down

0 comments on commit 85f8d80

Please sign in to comment.