kopia lustrzana https://github.com/micropython/micropython
extmod/modframebuf: Fix crash in FrameBuffer scrolling beyond extents.
Fixed the crash occurring when scrolling by at least the size of the framebuffer.pull/10093/head
rodzic
002f54ab4e
commit
bf49a087b2
|
@ -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) {
|
if (xstep < 0) {
|
||||||
sx = 0;
|
sx = 0;
|
||||||
xend = self->width + xstep;
|
xend = self->width + xstep;
|
||||||
|
if (xend <= 0) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
dx = 1;
|
dx = 1;
|
||||||
} else {
|
} else {
|
||||||
sx = self->width - 1;
|
sx = self->width - 1;
|
||||||
xend = xstep - 1;
|
xend = xstep - 1;
|
||||||
|
if (xend >= sx) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
dx = -1;
|
dx = -1;
|
||||||
}
|
}
|
||||||
if (ystep < 0) {
|
if (ystep < 0) {
|
||||||
y = 0;
|
y = 0;
|
||||||
yend = self->height + ystep;
|
yend = self->height + ystep;
|
||||||
|
if (yend <= 0) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
dy = 1;
|
dy = 1;
|
||||||
} else {
|
} else {
|
||||||
y = self->height - 1;
|
y = self->height - 1;
|
||||||
yend = ystep - 1;
|
yend = ystep - 1;
|
||||||
|
if (yend >= y) {
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
dy = -1;
|
dy = -1;
|
||||||
}
|
}
|
||||||
for (; y != yend; y += dy) {
|
for (; y != yend; y += dy) {
|
||||||
|
|
Ładowanie…
Reference in New Issue