Commit 074fb88
committed
dotclockframebuffer: fix gpio_data range validation
The upper-bound expression used `max_bit * 8` instead of
`gpio_data_len * 8`. With `gpio_data_len = 1` (the common case),
`max_bit` is 7 and the shift becomes `(1 << 56) - 1`, which is
undefined behavior on a 32-bit `mp_int_t`. In practice the
upper bound wraps to 1, so any `gpio_data` value > 1 raises
`ValueError: gpio_data must be 0..1` even though a full byte
is legitimate.
This blocks initializing displays through
`dotclockframebuffer.ioexpander_send_init_sequence(...)` when
the init sequence contains real one-byte register writes; e.g.
the Adafruit Qualia ESP32-S3 + 4" 480x480 round TFT crashes
during display init.
The fix is to use `gpio_data_len` (which is already the field
width in bytes) directly. For `gpio_data_len = 1` this gives
the correct `(1 << 8) - 1 = 255` upper bound.1 parent 6b4970b commit 074fb88
1 file changed
Lines changed: 1 addition & 1 deletion
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
0 commit comments