diff options
author | Radomir Dopieralski <openstack@sheep.art.pl> | 2017-07-24 12:58:30 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-07-25 12:29:02 +1000 |
commit | 363087aa11a5121ecff38f9e3a2372a42fa224ac (patch) | |
tree | 3517714e20a5164691986ef4de273ace2e54f7fd /extmod/modframebuf.c | |
parent | a10467b58ab92352217c7ab42eafd320bb671565 (diff) | |
download | micropython-363087aa11a5121ecff38f9e3a2372a42fa224ac.tar.gz micropython-363087aa11a5121ecff38f9e3a2372a42fa224ac.zip |
extmod/modframebuf: Fix invalid stride for odd widths in GS4_HMSB fmt.
Since the stride is specified in pixels, in a 4-bit horizontal format it
has to always be even, otherwise the computation is wrong and we can
write outside of the buffer sometimes.
Diffstat (limited to 'extmod/modframebuf.c')
-rw-r--r-- | extmod/modframebuf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 062a63c3b2..00a48379b6 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -237,12 +237,14 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size switch (o->format) { case FRAMEBUF_MVLSB: case FRAMEBUF_RGB565: - case FRAMEBUF_GS4_HMSB: break; case FRAMEBUF_MHLSB: case FRAMEBUF_MHMSB: o->stride = (o->stride + 7) & ~7; break; + case FRAMEBUF_GS4_HMSB: + o->stride = (o->stride + 1) & ~1; + break; default: mp_raise_ValueError("invalid format"); } |