File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,18 +98,19 @@ tSharedBuffer cGraphics_Amiga2::GetPalette(const std::string pFilename) {
9898 auto Palette = g_Resource->fileGet (Filename);
9999
100100 auto a0 = Palette->data ();
101- for (; a0 < Palette->data () + Palette->size (); ++a0) {
101+ auto a0End = Palette->data () + Palette->size ();
102+ for (; a0 + 2 < a0End; a0 += 3 ) {
102103
103- uint16 d0 = *a0++ ;
104- uint16 d1 = *a0++ ;
104+ uint16 d0 = a0[ 0 ] ;
105+ uint16 d1 = a0[ 1 ] ;
105106
106107 d0 &= 0xF0 ;
107108 d0 <<= 4 ;
108109
109110 d1 &= 0xF0 ;
110111 d0 |= d1;
111112
112- d1 = *a0 ;
113+ d1 = a0[ 2 ] ;
113114 d1 &= 0xF0 ;
114115 d1 >>= 4 ;
115116 d0 |= d1;
Original file line number Diff line number Diff line change @@ -98,7 +98,13 @@ struct sImage {
9898
9999 uint16 color;
100100
101- for (size_t ColorID = pStartColorID; ColorID < pStartColorID + pCount; ColorID++) {
101+ if (pStartColorID >= 256 )
102+ return ;
103+
104+ const size_t MaxColors = 256 - pStartColorID;
105+ const size_t PaletteCount = std::min (pCount, MaxColors);
106+
107+ for (size_t ColorID = pStartColorID; ColorID < pStartColorID + PaletteCount; ColorID++) {
102108
103109 // Get the next color codes
104110 color = readBEWord (pFrom);
You can’t perform that action at this time.
0 commit comments