UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.38k stars 428 forks source link

Possible bug in max7219 LED driver #470

Closed iliasam closed 1 year ago

iliasam commented 1 year ago

The issue

I meet a problem with max7219 driver when I was using it with 7-segment display: max7219_draw_text_7seg() function is not detecting zero bytes in null-terminated input string, which causes drawing wrong (not expected) symbols after good ones.

I checked the code of max7219_draw_text_7seg() function, and I think that there is a bug at 239 line of the driver:
while (s && pos < dev->digits) As I can understand from the code, the idea was to check that current symbol of the string is not null, null symbol stops drawing. But "s" is a pointer (address in memory), so it is not null and it should not became null. Changing this line to "while (*s && (pos < dev->digits))" is making this code sensitive to null-terminated strings and resolve the problem.

Which SDK are you using?

esp-idf

Which version of SDK are you using?

v4.4.2

Which build target have you used?

Component causing the issue

MAX7219

Anything in the logs that might be useful for us?

No response

Additional information or context

No response

Confirmation

UncleRus commented 1 year ago

Thank you!