Skip to content

Commit b272b88

Browse files
committed
Reject RLE-compressed BMP files
1 parent 2d1f334 commit b272b88

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,10 @@ msgstr ""
18321832
msgid "RISE_AND_FALL not available on this chip"
18331833
msgstr ""
18341834

1835+
#: shared-module/displayio/OnDiskBitmap.c
1836+
msgid "RLE-compressed BMP not supported"
1837+
msgstr ""
1838+
18351839
#: ports/stm/common-hal/os/__init__.c
18361840
msgid "RNG DeInit Error"
18371841
msgstr ""
@@ -1993,10 +1997,6 @@ msgstr ""
19931997
msgid "Stereo right must be on PWM channel B"
19941998
msgstr ""
19951999

1996-
#: ports/raspberrypi/common-hal/wifi/Radio.c
1997-
msgid "Stopping AP is not supported."
1998-
msgstr ""
1999-
20002000
#: shared-bindings/alarm/time/TimeAlarm.c
20012001
msgid "Supply one of monotonic_time or epoch_time"
20022002
msgstr ""

shared-module/displayio/OnDiskBitmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
6161
uint32_t compression = read_word(bmp_header, 15);
6262
uint32_t number_of_colors = read_word(bmp_header, 23);
6363

64+
// 0 is uncompressed; 3 is bitfield compressed. 1 and 2 are RLE compression.
65+
if (compression != 0 && compression != 3) {
66+
mp_raise_ValueError(MP_ERROR_TEXT("RLE-compressed BMP not supported"));
67+
}
68+
6469
bool indexed = bits_per_pixel <= 8;
6570
self->bitfield_compressed = (compression == 3);
6671
self->bits_per_pixel = bits_per_pixel;

0 commit comments

Comments
 (0)