diff options
author | TPReal <tpreal@gmail.com> | 2022-11-26 13:25:08 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-12-09 16:47:23 +1100 |
commit | bf49a087b2005e45f7ec5672f5ecd2668e2deb4f (patch) | |
tree | a5b92f4656b4db95aa0fe7ba4869fa0239d56b65 | |
parent | 002f54ab4edcc334b9641148dde94a6d7673c0fd (diff) |
extmod/modframebuf: Fix crash in FrameBuffer scrolling beyond extents.
Fixed the crash occurring when scrolling by at least the size of the
framebuffer.
-rw-r--r-- | extmod/modframebuf.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index e7825b591..87f7609dd 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -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) { |