Fixed resource cleanup.

This commit is contained in:
Armin Novak 2017-07-13 13:28:00 +02:00
parent b51a103b70
commit 478ca97a16
2 changed files with 33 additions and 15 deletions

View File

@ -735,6 +735,19 @@ static UINT drive_irp_request(DEVICE* device, IRP* irp)
return CHANNEL_RC_OK;
}
static void drive_free_resources(DRIVE_DEVICE* drive)
{
if (!drive)
return;
CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
}
/**
* Function description
*
@ -753,12 +766,7 @@ static UINT drive_free(DEVICE* device)
return error;
}
CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
drive_free_resources(drive);
return error;
}
@ -866,7 +874,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
return CHANNEL_RC_OK;
out_error:
drive_free((DEVICE*) drive);
drive_free_resources(drive);
return error;
}

View File

@ -182,8 +182,9 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
UINT32 tmp;
size_t pos1, pos2;
wStream* s;
RDPGFX_AVC444_BITMAP_STREAM h264;
RDPGFX_AVC444_BITMAP_STREAM h264 = { 0 };
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
s = Stream_New(cmd->data, cmd->length);
if (!s)
@ -193,21 +194,26 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
}
if (Stream_GetRemainingLength(s) < 4)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
Stream_Read_UINT32(s, tmp);
h264.cbAvc420EncodedBitstream1 = tmp & 0x3FFFFFFFUL;
h264.LC = (tmp >> 30UL) & 0x03UL;
if (h264.LC == 0x03)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
pos1 = Stream_GetPosition(s);
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[0].meta))))
{
WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
return error;
goto fail;
}
pos2 = Stream_GetPosition(s);
@ -218,7 +224,10 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
tmp = h264.cbAvc420EncodedBitstream1 - pos2 + pos1;
if (Stream_GetRemainingLength(s) < tmp)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
h264.bitstream[0].length = tmp;
Stream_Seek(s, tmp);
@ -226,7 +235,7 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[1].meta))))
{
WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
return error;
goto fail;
}
h264.bitstream[1].data = Stream_Pointer(s);
@ -238,7 +247,6 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
memset(&h264.bitstream[1], 0, sizeof(h264.bitstream[1]));
}
Stream_Free(s, FALSE);
cmd->extra = (void*) &h264;
if (context)
@ -249,6 +257,8 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
}
fail:
Stream_Free(s, FALSE);
free(h264.bitstream[0].meta.regionRects);
free(h264.bitstream[0].meta.quantQualityVals);
free(h264.bitstream[1].meta.regionRects);