Skip to content

Commit

Permalink
extmod/modframebuf: Fix crash in FrameBuffer scrolling beyond extents.
Browse files Browse the repository at this point in the history
Fixed the crash occurring when scrolling by at least the size of the
framebuffer.
  • Loading branch information
TPReal authored and dpgeorge committed Dec 9, 2022
1 parent 002f54a commit bf49a08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions extmod/modframebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,31 @@ STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ys
if (xstep < 0) {
sx = 0;
xend = self->width + xstep;
if (xend <= 0) {
return mp_const_none;
}
dx = 1;
} else {
sx = self->width - 1;
xend = xstep - 1;
if (xend >= sx) {
return mp_const_none;
}
dx = -1;
}
if (ystep < 0) {
y = 0;
yend = self->height + ystep;
if (yend <= 0) {
return mp_const_none;
}
dy = 1;
} else {
y = self->height - 1;
yend = ystep - 1;
if (yend >= y) {
return mp_const_none;
}
dy = -1;
}
for (; y != yend; y += dy) {
Expand Down

0 comments on commit bf49a08

Please sign in to comment.