Skip to content

Commit

Permalink
Add a check to draw.c:getPalette so it does not write out of bounds p…
Browse files Browse the repository at this point in the history
…ast the mapping static array into whatever static happens to come after: Fixes #2611 segfault (#2619)
  • Loading branch information
OvermindDL1 authored Jun 22, 2024
1 parent 18dacc0 commit f6a3caf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ static u8* getPalette(tic_mem* tic, u8* colors, u8 count)
{
static u8 mapping[TIC_PALETTE_SIZE];
for (s32 i = 0; i < TIC_PALETTE_SIZE; i++) mapping[i] = tic_tool_peek4(tic->ram->vram.mapping, i);
for (s32 i = 0; i < count; i++) mapping[colors[i]] = TRANSPARENT_COLOR;
for (s32 i = 0; i < count; i++) {
if (colors[i] < TIC_PALETTE_SIZE)
{
mapping[colors[i]] = TRANSPARENT_COLOR;
}
}
return mapping;
}

Expand Down

0 comments on commit f6a3caf

Please sign in to comment.