mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
Correctly detect going past the end of the pcx data.
palette is just that, the palette, and often won't point to the end of the pcx data. Use the right end :).
This commit is contained in:
parent
8ee13ef8c2
commit
0e521a7779
1 changed files with 4 additions and 3 deletions
|
@ -55,6 +55,7 @@ LoadPCX (QFile *f, qboolean convert, byte *pal)
|
|||
pcx_t *pcx;
|
||||
int pcx_mark;
|
||||
byte *palette;
|
||||
byte *end;
|
||||
byte *pix;
|
||||
byte *dataByte;
|
||||
int runLength = 1;
|
||||
|
@ -85,7 +86,7 @@ LoadPCX (QFile *f, qboolean convert, byte *pal)
|
|||
return 0;
|
||||
}
|
||||
|
||||
palette = ((byte *) pcx) + fsize - 768;
|
||||
end = palette = ((byte *) pcx) + fsize - 768;
|
||||
dataByte = (byte *) &pcx[1];
|
||||
|
||||
count = (pcx->xmax + 1) * (pcx->ymax + 1);
|
||||
|
@ -106,12 +107,12 @@ LoadPCX (QFile *f, qboolean convert, byte *pal)
|
|||
pix = tex->data;
|
||||
|
||||
while (count) {
|
||||
if (dataByte >= palette)
|
||||
if (dataByte >= end)
|
||||
break;
|
||||
|
||||
if ((*dataByte & 0xC0) == 0xC0) {
|
||||
runLength = *dataByte++ & 0x3F;
|
||||
if (dataByte >= palette)
|
||||
if (dataByte >= end)
|
||||
break;
|
||||
} else {
|
||||
runLength = 1;
|
||||
|
|
Loading…
Reference in a new issue