Fixed crashes.

This commit is contained in:
Armin Novak 2016-04-13 12:32:51 +02:00
parent da956e0388
commit 5633f5242a
4 changed files with 72 additions and 89 deletions

View File

@ -443,10 +443,10 @@ BOOL freerdp_image_copy(BYTE* pDstData, DWORD DstFormat,
break;
}
if (nDstStep < 0)
if (nDstStep <= 0)
nDstStep = nWidth * GetBytesPerPixel(DstFormat);
if (nSrcStep < 0)
if (nSrcStep <= 0)
nSrcStep = nWidth * GetBytesPerPixel(SrcFormat);
if (vSrcVFlip)

View File

@ -270,79 +270,65 @@ INT32 interleaved_decompress(BITMAP_INTERLEAVED_CONTEXT* interleaved,
if (nDstStep < 0)
nDstStep = nWidth * dstBytesPerPixel;
if (bpp == 24)
switch(bpp)
{
case 24:
scanline = nWidth * 3;
BufferSize = scanline * nHeight;
SrcFormat = PIXEL_FORMAT_BGR24_VF;
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
interleaved->TempSize = BufferSize;
}
if (!interleaved->TempBuffer)
return -1;
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
nWidth, nHeight, interleaved->TempBuffer,
SrcFormat, scanline, 0, 0, palette);
}
else if ((bpp == 16) || (bpp == 15))
{
SrcFormat = PIXEL_FORMAT_RGB24_VF;
break;
case 16:
scanline = nWidth * 2;
BufferSize = scanline * nHeight;
SrcFormat = (bpp == 16) ? PIXEL_FORMAT_RGB16_VF : PIXEL_FORMAT_RGB15_VF;
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
interleaved->TempSize = BufferSize;
}
if (!interleaved->TempBuffer)
return -1;
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
status = freerdp_image_copy(pDstData, DstFormat, nDstStep,
nXDst, nYDst, nWidth, nHeight,
interleaved->TempBuffer, SrcFormat,
scanline, 0, 0, palette);
}
else if (bpp == 8)
{
SrcFormat = PIXEL_FORMAT_RGB16_VF;
break;
case 15:
scanline = nWidth * 2;
SrcFormat = PIXEL_FORMAT_RGB15_VF;
break;
case 8:
scanline = nWidth;
BufferSize = scanline * nHeight;
SrcFormat = PIXEL_FORMAT_RGB8_VF;
break;
default:
WLog_ERR(TAG, "Invalid color depth %d", bpp);
return -1;
}
BufferSize = scanline * nHeight;
if (BufferSize > interleaved->TempSize)
{
interleaved->TempBuffer = _aligned_realloc(interleaved->TempBuffer, BufferSize, 16);
interleaved->TempBuffer = _aligned_realloc(
interleaved->TempBuffer,
BufferSize, 16);
interleaved->TempSize = BufferSize;
}
if (!interleaved->TempBuffer)
return -1;
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer, scanline, nWidth, nHeight);
switch(bpp)
{
case 24:
RleDecompress24to24(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nWidth, nHeight);
break;
case 16:
case 15:
RleDecompress16to16(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nWidth, nHeight);
break;
case 8:
RleDecompress8to8(pSrcData, SrcSize, interleaved->TempBuffer,
scanline, nWidth, nHeight);
break;
default:
return -1;
}
status = freerdp_image_copy(pDstData, DstFormat, nDstStep, nXDst, nYDst,
nWidth, nHeight, interleaved->TempBuffer,
SrcFormat, scanline, 0, 0, palette);
}
else
{
return -1;
}
return 1;
return status;
}
BOOL interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved,

View File

@ -57,7 +57,6 @@ void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap)
if (bitmap->data)
_aligned_free(bitmap->data);
memset(bitmap, 0, sizeof(rdpBitmap));
free(bitmap);
}
}

View File

@ -509,8 +509,8 @@ static BOOL gdi_bitmap_update(rdpContext* context,
{
if (bitsPerPixel < 32)
{
if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_INTERLEAVED,
gdi->width, gdi->height))
if (!freerdp_client_codecs_prepare(
codecs, FREERDP_CODEC_INTERLEAVED))
return FALSE;
status = interleaved_decompress(codecs->interleaved,
@ -524,8 +524,8 @@ static BOOL gdi_bitmap_update(rdpContext* context,
}
else
{
if (!freerdp_client_codecs_prepare(codecs, FREERDP_CODEC_PLANAR,
gdi->width, gdi->height))
if (!freerdp_client_codecs_prepare(
codecs, FREERDP_CODEC_PLANAR))
return FALSE;
status = planar_decompress(codecs->planar, pSrcData, SrcSize, &gdi->bitmap_buffer,
@ -1087,8 +1087,7 @@ static BOOL gdi_surface_bits(rdpContext* context,
{
case RDP_CODEC_ID_REMOTEFX:
{
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_REMOTEFX,
gdi->width, gdi->height))
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_REMOTEFX))
return FALSE;
pDstData = gdi->bitmap_buffer;
@ -1106,8 +1105,7 @@ static BOOL gdi_surface_bits(rdpContext* context,
break;
case RDP_CODEC_ID_NSCODEC:
{
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_NSCODEC,
gdi->width, gdi->height))
if (!freerdp_client_codecs_prepare(gdi->codecs, FREERDP_CODEC_NSCODEC))
return FALSE;
if (!nsc_process_message(gdi->codecs->nsc, cmd->bpp, cmd->width,