Skip to content

Commit 2556fce

Browse files
committed
OnDiskBitmap: Fix memory corruption when using palette image
The number of palette entries set was accidentally 4x too much, because the wrong looping variable was used.
1 parent 3c25d8e commit 2556fce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shared-module/displayio/OnDiskBitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
108108
if (palette_bytes_read != palette_size) {
109109
mp_raise_ValueError(translate("Unable to read color palette data"));
110110
}
111-
for (uint16_t i = 0; i < palette_size; i++) {
111+
for (uint16_t i = 0; i < number_of_colors; i++) {
112112
common_hal_displayio_palette_set_color(palette, i, palette_data[i]);
113113
}
114114
m_free(palette_data);

0 commit comments

Comments
 (0)