Skip to content

Commit

Permalink
fix: crash loop on new chip
Browse files Browse the repository at this point in the history
changes: skip reading bitmaps on invalid magic header
  • Loading branch information
kienvo committed Sep 5, 2024
1 parent a8b32e9 commit 002c337
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ uint16_t data_flash2newmem(uint8_t **chunk, uint32_t n)
{
data_legacy_t *header = data_get_header(0);

if (memcmp(header->header, "wang", 5))
return 0;

uint16_t size = bswap16(header->sizes[n]) * LED_ROWS;
if (size == 0)
return 0;
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ void play_splash(xbm_t *xbm, int col, int row)

void load_bmlist()
{
if (data_get_header(0) == 0) // There is no bitmap stored in flash
return; // skip

bm_t *curr_bm = bmlist_current();

for (int i=0; i<8; i++) {
Expand Down

0 comments on commit 002c337

Please sign in to comment.