From 9218712ecfea0aeafe80acbc60ad04500b9e3e39 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 5 Apr 2019 10:04:01 +0200 Subject: [PATCH] Remove unnecessary clipboard data copy. --- channels/cliprdr/server/cliprdr_main.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index c2a0f7ad2..fa2206569 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -929,36 +929,28 @@ static UINT cliprdr_server_receive_format_data_response( { CLIPRDR_FORMAT_DATA_RESPONSE formatDataResponse; UINT error = CHANNEL_RC_OK; - BYTE* requestedFormatData = NULL; + WLog_DBG(TAG, "CliprdrClientFormatDataResponse"); formatDataResponse.msgType = CB_FORMAT_DATA_RESPONSE; formatDataResponse.msgFlags = header->msgFlags; formatDataResponse.dataLen = header->dataLen; formatDataResponse.requestedFormatData = NULL; - if (Stream_GetRemainingLength(s) < header->dataLen) + if (header->dataLen) + formatDataResponse.requestedFormatData = Stream_Pointer(s); + + if (!Stream_SafeSeek(s, header->dataLen)) { WLog_ERR(TAG, "not enough data in stream!"); return ERROR_INVALID_DATA; } - if (header->dataLen) - { - requestedFormatData = (BYTE*) malloc(header->dataLen); - if (!requestedFormatData) - return ERROR_OUTOFMEMORY; - - Stream_Read(s, requestedFormatData, header->dataLen); - formatDataResponse.requestedFormatData = requestedFormatData; - } - IFCALLRET(context->ClientFormatDataResponse, error, context, &formatDataResponse); if (error) WLog_ERR(TAG, "ClientFormatDataResponse failed with error %"PRIu32"!", error); - free(requestedFormatData); return error; }