mirror of https://github.com/FreeRDP/FreeRDP
Fixed return value check for callbacks.
This commit is contained in:
parent
71e38a4ce7
commit
f68bc07a22
|
@ -28,19 +28,20 @@
|
|||
|
||||
#define TAG FREERDP_TAG("core.surface")
|
||||
|
||||
static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length)
|
||||
static BOOL update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length)
|
||||
{
|
||||
int pos;
|
||||
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 20)
|
||||
return -1;
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT16(s, cmd->destLeft);
|
||||
Stream_Read_UINT16(s, cmd->destTop);
|
||||
Stream_Read_UINT16(s, cmd->destRight);
|
||||
Stream_Read_UINT16(s, cmd->destBottom);
|
||||
Stream_Read_UINT8(s, cmd->bpp);
|
||||
|
||||
if ((cmd->bpp < 1) || (cmd->bpp > 32))
|
||||
{
|
||||
WLog_ERR(TAG, "invalid bpp value %"PRIu32"", cmd->bpp);
|
||||
|
@ -54,38 +55,43 @@ static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT3
|
|||
Stream_Read_UINT32(s, cmd->bitmapDataLength);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < cmd->bitmapDataLength)
|
||||
return -1;
|
||||
return FALSE;
|
||||
|
||||
pos = Stream_GetPosition(s) + cmd->bitmapDataLength;
|
||||
cmd->bitmapData = Stream_Pointer(s);
|
||||
|
||||
Stream_SetPosition(s, pos);
|
||||
*length = 20 + cmd->bitmapDataLength;
|
||||
|
||||
IFCALL(update->SurfaceBits, update->context, cmd);
|
||||
if (!update->SurfaceBits)
|
||||
{
|
||||
WLog_ERR(TAG, "Missing callback update->SurfaceBits");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return update->SurfaceBits(update->context, cmd);
|
||||
}
|
||||
|
||||
static int update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s, UINT32 *length)
|
||||
static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s, UINT32* length)
|
||||
{
|
||||
SURFACE_FRAME_MARKER* marker = &update->surface_frame_marker;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 6)
|
||||
return -1;
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT16(s, marker->frameAction);
|
||||
Stream_Read_UINT32(s, marker->frameId);
|
||||
|
||||
WLog_Print(update->log, WLOG_DEBUG, "SurfaceFrameMarker: action: %s (%"PRIu32") id: %"PRIu32"",
|
||||
(!marker->frameAction) ? "Begin" : "End",
|
||||
marker->frameAction, marker->frameId);
|
||||
(!marker->frameAction) ? "Begin" : "End",
|
||||
marker->frameAction, marker->frameId);
|
||||
|
||||
IFCALL(update->SurfaceFrameMarker, update->context, marker);
|
||||
if (!update->SurfaceFrameMarker)
|
||||
{
|
||||
WLog_ERR(TAG, "Missing callback update->SurfaceFrameMarker");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*length = 6;
|
||||
|
||||
return 0;
|
||||
return update->SurfaceFrameMarker(update->context, marker);
|
||||
}
|
||||
|
||||
int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s)
|
||||
|
@ -97,7 +103,6 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s)
|
|||
while (size > 2)
|
||||
{
|
||||
Stream_GetPointer(s, mark);
|
||||
|
||||
Stream_Read_UINT16(s, cmdType);
|
||||
size -= 2;
|
||||
|
||||
|
@ -105,13 +110,15 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s)
|
|||
{
|
||||
case CMDTYPE_SET_SURFACE_BITS:
|
||||
case CMDTYPE_STREAM_SURFACE_BITS:
|
||||
if (update_recv_surfcmd_surface_bits(update, s, &cmdLength) < 0)
|
||||
if (!update_recv_surfcmd_surface_bits(update, s, &cmdLength))
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
case CMDTYPE_FRAME_MARKER:
|
||||
if (update_recv_surfcmd_frame_marker(update, s, &cmdLength) < 0)
|
||||
if (!update_recv_surfcmd_frame_marker(update, s, &cmdLength))
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -133,13 +140,12 @@ int update_recv_surfcmds(rdpUpdate* update, UINT32 size, wStream* s)
|
|||
}
|
||||
|
||||
BOOL update_write_surfcmd_surface_bits_header(wStream* s,
|
||||
const SURFACE_BITS_COMMAND* cmd)
|
||||
const SURFACE_BITS_COMMAND* cmd)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, SURFCMD_SURFACE_BITS_HEADER_LENGTH))
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT16(s, CMDTYPE_STREAM_SURFACE_BITS);
|
||||
|
||||
Stream_Write_UINT16(s, cmd->destLeft);
|
||||
Stream_Write_UINT16(s, cmd->destTop);
|
||||
Stream_Write_UINT16(s, cmd->destRight);
|
||||
|
@ -150,7 +156,6 @@ BOOL update_write_surfcmd_surface_bits_header(wStream* s,
|
|||
Stream_Write_UINT16(s, cmd->width);
|
||||
Stream_Write_UINT16(s, cmd->height);
|
||||
Stream_Write_UINT32(s, cmd->bitmapDataLength);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -160,7 +165,6 @@ BOOL update_write_surfcmd_frame_marker(wStream* s, UINT16 frameAction, UINT32 fr
|
|||
return FALSE;
|
||||
|
||||
Stream_Write_UINT16(s, CMDTYPE_FRAME_MARKER);
|
||||
|
||||
Stream_Write_UINT16(s, frameAction);
|
||||
Stream_Write_UINT32(s, frameId);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in New Issue