Skip to content

Commit b7e31c7

Browse files
authored
Merge pull request #116 from OpenFodder/codex/fix-palette-overflow-in-ilbm-parser
Fix CMAP palette bounds in Amiga ILBM decoder
2 parents 8bd0376 + a204e69 commit b7e31c7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Source/Amiga/Graphics_Amiga.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,11 @@ sImage cGraphics_Amiga::DecodeIFF(const std::string& pFilename) {
618618
d0 = (int16)d0;
619619
Final += d0;
620620

621-
Result.mPalette[i].mRed = ((Final >> 8) & 0xF) << 2;
622-
Result.mPalette[i].mGreen = ((Final >> 4) & 0xF) << 2;
623-
Result.mPalette[i].mBlue = ((Final >> 0) & 0xF) << 2;
621+
if (i < 256) {
622+
Result.mPalette[i].mRed = ((Final >> 8) & 0xF) << 2;
623+
Result.mPalette[i].mGreen = ((Final >> 4) & 0xF) << 2;
624+
Result.mPalette[i].mBlue = ((Final >> 0) & 0xF) << 2;
625+
}
624626

625627
FileSize -= 3;
626628

0 commit comments

Comments
 (0)