Added parameter checks.

This commit is contained in:
Armin Novak 2018-10-16 17:23:24 +02:00
parent d2e08c0aa8
commit bbcba568f4
2 changed files with 22 additions and 8 deletions

View File

@ -292,7 +292,7 @@ static INLINE BYTE* WRITEFIRSTLINEFGBGIMAGE(BYTE* pbDest, BYTE bitmask,
/**
* Decompress an RLE compressed bitmap.
*/
static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
static INLINE BOOL RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
BYTE* pbDestBuffer,
UINT32 rowDelta, UINT32 width, UINT32 height)
{
@ -310,6 +310,9 @@ static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
UINT32 advance;
RLEEXTRA
if (!pbSrcBuffer || !pbDestBuffer)
return FALSE;
while (pbSrc < pbEnd)
{
/* Watch out for the end of the first scanline. */
@ -628,6 +631,11 @@ static INLINE void RLEDECOMPRESS(const BYTE* pbSrcBuffer, UINT32 cbSrcBuffer,
DESTWRITEPIXEL(pbDest, BLACK_PIXEL);
DESTNEXTPIXEL(pbDest);
break;
default:
return FALSE;
}
}
return TRUE;
}

View File

@ -276,7 +276,7 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
UINT32 SrcFormat;
UINT32 BufferSize;
if (!interleaved)
if (!interleaved || !pSrcData || !pDstData)
return FALSE;
switch (bpp)
@ -322,19 +322,25 @@ BOOL interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
switch (bpp)
{
case 24:
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight);
if (!RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight))
return FALSE;
break;
case 16:
case 15:
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight);
if (!RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight))
return FALSE;
break;
case 8:
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight);
if (!RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nSrcWidth, nSrcHeight))
return FALSE;
break;
default: