Skip to content

Commit 363087a

Browse files
deshipudpgeorge
authored andcommitted
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.
1 parent a10467b commit 363087a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

extmod/modframebuf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,14 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size
237237
switch (o->format) {
238238
case FRAMEBUF_MVLSB:
239239
case FRAMEBUF_RGB565:
240-
case FRAMEBUF_GS4_HMSB:
241240
break;
242241
case FRAMEBUF_MHLSB:
243242
case FRAMEBUF_MHMSB:
244243
o->stride = (o->stride + 7) & ~7;
245244
break;
245+
case FRAMEBUF_GS4_HMSB:
246+
o->stride = (o->stride + 1) & ~1;
247+
break;
246248
default:
247249
mp_raise_ValueError("invalid format");
248250
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy