mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: fix memory leaks
This commit is contained in:
parent
f3d4da3cf9
commit
e1d0fad519
|
@ -1249,6 +1249,7 @@ int main(int argc, char* argv[])
|
||||||
instance->context_size = sizeof(xfContext);
|
instance->context_size = sizeof(xfContext);
|
||||||
instance->ContextNew = (pContextNew) xf_context_new;
|
instance->ContextNew = (pContextNew) xf_context_new;
|
||||||
instance->ContextFree = (pContextFree) xf_context_free;
|
instance->ContextFree = (pContextFree) xf_context_free;
|
||||||
|
//instance->flags = FREERDP_FLAG_ASYNC_UPDATE;
|
||||||
freerdp_context_new(instance);
|
freerdp_context_new(instance);
|
||||||
|
|
||||||
instance->context->argc = argc;
|
instance->context->argc = argc;
|
||||||
|
|
|
@ -341,6 +341,9 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
|
||||||
detect_status = 1;
|
detect_status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings->ServerHostname)
|
||||||
|
free(settings->ServerHostname);
|
||||||
|
|
||||||
free(settings);
|
free(settings);
|
||||||
|
|
||||||
return detect_status;
|
return detect_status;
|
||||||
|
|
|
@ -103,6 +103,8 @@ struct rdp_context
|
||||||
UINT32 paddingC[64 - 41]; /* 41 */
|
UINT32 paddingC[64 - 41]; /* 41 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FREERDP_FLAG_ASYNC_UPDATE 0x00000001
|
||||||
|
|
||||||
/** Defines the options for a given instance of RDP connection.
|
/** Defines the options for a given instance of RDP connection.
|
||||||
* This is built by the client and given to the FreeRDP library to create the connection
|
* This is built by the client and given to the FreeRDP library to create the connection
|
||||||
* with the expected options.
|
* with the expected options.
|
||||||
|
@ -118,8 +120,11 @@ struct rdp_freerdp
|
||||||
When using this capability, client application should ALWAYS declare their structure with the
|
When using this capability, client application should ALWAYS declare their structure with the
|
||||||
rdpContext field first, and any additional content following it.
|
rdpContext field first, and any additional content following it.
|
||||||
Can be allocated by a call to freerdp_context_new().
|
Can be allocated by a call to freerdp_context_new().
|
||||||
Must be dealocated by a call to freerdp_context_free() before deallocating the current instance. */
|
Must be deallocated by a call to freerdp_context_free() before deallocating the current instance. */
|
||||||
UINT32 paddingA[16 - 1]; /* 1 */
|
|
||||||
|
UINT32 flags; /**< (offset 1) context flags, can be set prior to freerdp_context_new() */
|
||||||
|
|
||||||
|
UINT32 paddingA[16 - 2]; /* 2 */
|
||||||
|
|
||||||
rdpInput* input; /* (offset 16)
|
rdpInput* input; /* (offset 16)
|
||||||
Input handle for the connection.
|
Input handle for the connection.
|
||||||
|
|
|
@ -155,7 +155,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w
|
||||||
for (y = 0; y < subband_width; y++)
|
for (y = 0; y < subband_width; y++)
|
||||||
{
|
{
|
||||||
/* Even coefficients */
|
/* Even coefficients */
|
||||||
for (n = 0; n < subband_width; n+=8)
|
for (n = 0; n < subband_width; n += 8)
|
||||||
{
|
{
|
||||||
/* dst[2n] = l[n] - ((h[n-1] + h[n] + 1) >> 1); */
|
/* dst[2n] = l[n] - ((h[n-1] + h[n] + 1) >> 1); */
|
||||||
|
|
||||||
|
@ -163,6 +163,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w
|
||||||
|
|
||||||
h_n = _mm_load_si128((__m128i*) h_ptr);
|
h_n = _mm_load_si128((__m128i*) h_ptr);
|
||||||
h_n_m = _mm_loadu_si128((__m128i*) (h_ptr - 1));
|
h_n_m = _mm_loadu_si128((__m128i*) (h_ptr - 1));
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
first = _mm_extract_epi16(h_n_m, 1);
|
first = _mm_extract_epi16(h_n_m, 1);
|
||||||
|
@ -177,14 +178,15 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w
|
||||||
|
|
||||||
_mm_store_si128((__m128i*) l_ptr, dst_n);
|
_mm_store_si128((__m128i*) l_ptr, dst_n);
|
||||||
|
|
||||||
l_ptr+=8;
|
l_ptr += 8;
|
||||||
h_ptr+=8;
|
h_ptr += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_ptr -= subband_width;
|
l_ptr -= subband_width;
|
||||||
h_ptr -= subband_width;
|
h_ptr -= subband_width;
|
||||||
|
|
||||||
/* Odd coefficients */
|
/* Odd coefficients */
|
||||||
for (n = 0; n < subband_width; n+=8)
|
for (n = 0; n < subband_width; n += 8)
|
||||||
{
|
{
|
||||||
/* dst[2n + 1] = (h[n] << 1) + ((dst[2n] + dst[2n + 2]) >> 1); */
|
/* dst[2n + 1] = (h[n] << 1) + ((dst[2n] + dst[2n + 2]) >> 1); */
|
||||||
|
|
||||||
|
@ -194,6 +196,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w
|
||||||
|
|
||||||
dst_n = _mm_load_si128((__m128i*) (l_ptr));
|
dst_n = _mm_load_si128((__m128i*) (l_ptr));
|
||||||
dst_n_p = _mm_loadu_si128((__m128i*) (l_ptr + 1));
|
dst_n_p = _mm_loadu_si128((__m128i*) (l_ptr + 1));
|
||||||
|
|
||||||
if (n == subband_width - 8)
|
if (n == subband_width - 8)
|
||||||
{
|
{
|
||||||
last = _mm_extract_epi16(dst_n_p, 6);
|
last = _mm_extract_epi16(dst_n_p, 6);
|
||||||
|
@ -211,9 +214,9 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w
|
||||||
_mm_store_si128((__m128i*) dst_ptr, dst1);
|
_mm_store_si128((__m128i*) dst_ptr, dst1);
|
||||||
_mm_store_si128((__m128i*) (dst_ptr + 8), dst2);
|
_mm_store_si128((__m128i*) (dst_ptr + 8), dst2);
|
||||||
|
|
||||||
l_ptr+=8;
|
l_ptr += 8;
|
||||||
h_ptr+=8;
|
h_ptr += 8;
|
||||||
dst_ptr+=16;
|
dst_ptr += 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,10 +309,10 @@ freerdp* freerdp_new()
|
||||||
freerdp* instance;
|
freerdp* instance;
|
||||||
|
|
||||||
instance = (freerdp*) malloc(sizeof(freerdp));
|
instance = (freerdp*) malloc(sizeof(freerdp));
|
||||||
ZeroMemory(instance, sizeof(freerdp));
|
|
||||||
|
|
||||||
if (instance != NULL)
|
if (instance)
|
||||||
{
|
{
|
||||||
|
ZeroMemory(instance, sizeof(freerdp));
|
||||||
instance->context_size = sizeof(rdpContext);
|
instance->context_size = sizeof(rdpContext);
|
||||||
instance->SendChannelData = freerdp_send_channel_data;
|
instance->SendChannelData = freerdp_send_channel_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,13 @@ static void message_EndPaint(rdpContext* context)
|
||||||
|
|
||||||
static void message_SetBounds(rdpContext* context, rdpBounds* bounds)
|
static void message_SetBounds(rdpContext* context, rdpBounds* bounds)
|
||||||
{
|
{
|
||||||
rdpBounds* wParam;
|
rdpBounds* wParam = NULL;
|
||||||
|
|
||||||
wParam = (rdpBounds*) malloc(sizeof(rdpBounds));
|
if (bounds)
|
||||||
CopyMemory(wParam, bounds, sizeof(rdpBounds));
|
{
|
||||||
|
wParam = (rdpBounds*) malloc(sizeof(rdpBounds));
|
||||||
|
CopyMemory(wParam, bounds, sizeof(rdpBounds));
|
||||||
|
}
|
||||||
|
|
||||||
MessageQueue_Post(context->update->queue, (void*) context,
|
MessageQueue_Post(context->update->queue, (void*) context,
|
||||||
MakeMessageId(Update, SetBounds), (void*) wParam, NULL);
|
MakeMessageId(Update, SetBounds), (void*) wParam, NULL);
|
||||||
|
@ -534,8 +537,8 @@ static void message_CacheBrush(rdpContext* context, CACHE_BRUSH_ORDER* cacheBrus
|
||||||
wParam = (CACHE_BRUSH_ORDER*) malloc(sizeof(CACHE_BRUSH_ORDER));
|
wParam = (CACHE_BRUSH_ORDER*) malloc(sizeof(CACHE_BRUSH_ORDER));
|
||||||
CopyMemory(wParam, cacheBrushOrder, sizeof(CACHE_BRUSH_ORDER));
|
CopyMemory(wParam, cacheBrushOrder, sizeof(CACHE_BRUSH_ORDER));
|
||||||
|
|
||||||
wParam->data = (BYTE*) malloc(wParam->length);
|
//wParam->data = (BYTE*) malloc(wParam->length);
|
||||||
CopyMemory(wParam->data, cacheBrushOrder->data, wParam->length);
|
//CopyMemory(wParam->data, cacheBrushOrder->data, wParam->length);
|
||||||
|
|
||||||
MessageQueue_Post(context->update->queue, (void*) context,
|
MessageQueue_Post(context->update->queue, (void*) context,
|
||||||
MakeMessageId(SecondaryUpdate, CacheBrush), (void*) wParam, NULL);
|
MakeMessageId(SecondaryUpdate, CacheBrush), (void*) wParam, NULL);
|
||||||
|
@ -1126,7 +1129,8 @@ int message_process_update_class(rdpMessage* update, wMessage* msg, int type)
|
||||||
|
|
||||||
case Update_SetBounds:
|
case Update_SetBounds:
|
||||||
IFCALL(update->SetBounds, msg->context, (rdpBounds*) msg->wParam);
|
IFCALL(update->SetBounds, msg->context, (rdpBounds*) msg->wParam);
|
||||||
free(msg->wParam);
|
if (msg->wParam)
|
||||||
|
free(msg->wParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Update_Synchronize:
|
case Update_Synchronize:
|
||||||
|
@ -1367,7 +1371,7 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
|
||||||
{
|
{
|
||||||
CACHE_BITMAP_V2_ORDER* wParam = (CACHE_BITMAP_V2_ORDER*) msg->wParam;
|
CACHE_BITMAP_V2_ORDER* wParam = (CACHE_BITMAP_V2_ORDER*) msg->wParam;
|
||||||
|
|
||||||
free(wParam->bitmapDataStream);
|
//free(wParam->bitmapDataStream);
|
||||||
free(wParam);
|
free(wParam);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1423,7 +1427,7 @@ int message_process_secondary_update_class(rdpMessage* update, wMessage* msg, in
|
||||||
{
|
{
|
||||||
CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*) msg->wParam;
|
CACHE_BRUSH_ORDER* wParam = (CACHE_BRUSH_ORDER*) msg->wParam;
|
||||||
|
|
||||||
free(wParam->data);
|
//free(wParam->data);
|
||||||
free(wParam);
|
free(wParam);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -678,10 +678,6 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||||
return 0; /* Packet is not yet completely received. */
|
return 0; /* Packet is not yet completely received. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* A complete packet has been received. In case there are trailing data
|
|
||||||
* for the next packet, we copy it to the new receive buffer.
|
|
||||||
*/
|
|
||||||
received = transport->ReceiveBuffer;
|
received = transport->ReceiveBuffer;
|
||||||
transport->ReceiveBuffer = transport_receive_pool_take(transport);
|
transport->ReceiveBuffer = transport_receive_pool_take(transport);
|
||||||
|
|
||||||
|
@ -697,11 +693,9 @@ int transport_check_fds(rdpTransport** ptransport)
|
||||||
* 1: asynchronous return
|
* 1: asynchronous return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ReferenceTable_Add(transport->ReceiveReferences, received);
|
|
||||||
|
|
||||||
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
|
recv_status = transport->ReceiveCallback(transport, received, transport->ReceiveExtra);
|
||||||
|
|
||||||
ReferenceTable_Release(transport->ReceiveReferences, received);
|
transport_receive_pool_return(transport, received);
|
||||||
|
|
||||||
if (recv_status < 0)
|
if (recv_status < 0)
|
||||||
status = -1;
|
status = -1;
|
||||||
|
@ -749,7 +743,9 @@ STREAM* transport_receive_pool_take(rdpTransport* transport)
|
||||||
pdu = Queue_Dequeue(transport->ReceivePool);
|
pdu = Queue_Dequeue(transport->ReceivePool);
|
||||||
|
|
||||||
if (!pdu)
|
if (!pdu)
|
||||||
|
{
|
||||||
pdu = stream_new(BUFFER_SIZE);
|
pdu = stream_new(BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
pdu->p = pdu->data;
|
pdu->p = pdu->data;
|
||||||
|
|
||||||
|
@ -778,8 +774,13 @@ rdpTransport* transport_new(rdpSettings* settings)
|
||||||
/* a small 0.1ms delay when transport is blocking. */
|
/* a small 0.1ms delay when transport is blocking. */
|
||||||
transport->SleepInterval = 100;
|
transport->SleepInterval = 100;
|
||||||
|
|
||||||
|
transport->ReceivePool = Queue_New(TRUE, -1, -1);
|
||||||
|
transport->ReceiveQueue = Queue_New(TRUE, -1, -1);
|
||||||
|
Queue_Object(transport->ReceivePool)->fnObjectFree = (OBJECT_FREE_FN) stream_free;
|
||||||
|
Queue_Object(transport->ReceiveQueue)->fnObjectFree = (OBJECT_FREE_FN) stream_free;
|
||||||
|
|
||||||
/* receive buffer for non-blocking read. */
|
/* receive buffer for non-blocking read. */
|
||||||
transport->ReceiveBuffer = stream_new(BUFFER_SIZE);
|
transport->ReceiveBuffer = transport_receive_pool_take(transport);
|
||||||
transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
transport->ReceiveEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
/* buffers for blocking read/write */
|
/* buffers for blocking read/write */
|
||||||
|
@ -789,14 +790,6 @@ rdpTransport* transport_new(rdpSettings* settings)
|
||||||
transport->blocking = TRUE;
|
transport->blocking = TRUE;
|
||||||
|
|
||||||
transport->layer = TRANSPORT_LAYER_TCP;
|
transport->layer = TRANSPORT_LAYER_TCP;
|
||||||
|
|
||||||
transport->ReceivePool = Queue_New(TRUE, -1, -1);
|
|
||||||
transport->ReceiveQueue = Queue_New(TRUE, -1, -1);
|
|
||||||
Queue_Object(transport->ReceivePool)->fnObjectFree = (OBJECT_FREE_FN) stream_free;
|
|
||||||
Queue_Object(transport->ReceiveQueue)->fnObjectFree = (OBJECT_FREE_FN) stream_free;
|
|
||||||
|
|
||||||
transport->ReceiveReferences = ReferenceTable_New(TRUE,
|
|
||||||
(void*) transport, (REFERENCE_FREE) transport_receive_pool_return);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return transport;
|
return transport;
|
||||||
|
@ -806,7 +799,9 @@ void transport_free(rdpTransport* transport)
|
||||||
{
|
{
|
||||||
if (transport != NULL)
|
if (transport != NULL)
|
||||||
{
|
{
|
||||||
stream_free(transport->ReceiveBuffer);
|
if (transport->ReceiveBuffer)
|
||||||
|
stream_free(transport->ReceiveBuffer);
|
||||||
|
|
||||||
stream_free(transport->ReceiveStream);
|
stream_free(transport->ReceiveStream);
|
||||||
stream_free(transport->SendStream);
|
stream_free(transport->SendStream);
|
||||||
CloseHandle(transport->ReceiveEvent);
|
CloseHandle(transport->ReceiveEvent);
|
||||||
|
@ -827,8 +822,6 @@ void transport_free(rdpTransport* transport)
|
||||||
Queue_Free(transport->ReceivePool);
|
Queue_Free(transport->ReceivePool);
|
||||||
Queue_Free(transport->ReceiveQueue);
|
Queue_Free(transport->ReceiveQueue);
|
||||||
|
|
||||||
ReferenceTable_Free(transport->ReceiveReferences);
|
|
||||||
|
|
||||||
free(transport);
|
free(transport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,6 @@ struct rdp_transport
|
||||||
|
|
||||||
wQueue* ReceivePool;
|
wQueue* ReceivePool;
|
||||||
wQueue* ReceiveQueue;
|
wQueue* ReceiveQueue;
|
||||||
|
|
||||||
wReferenceTable* ReceiveReferences;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
STREAM* transport_recv_stream_init(rdpTransport* transport, int size);
|
STREAM* transport_recv_stream_init(rdpTransport* transport, int size);
|
||||||
|
|
|
@ -764,7 +764,7 @@ rdpUpdate* update_new(rdpRdp* rdp)
|
||||||
update->SuppressOutput = update_send_suppress_output;
|
update->SuppressOutput = update_send_suppress_output;
|
||||||
|
|
||||||
update->initialState = TRUE;
|
update->initialState = TRUE;
|
||||||
//update->asynchronous = TRUE;
|
update->asynchronous = (rdp->instance->flags & FREERDP_FLAG_ASYNC_UPDATE) ? TRUE : FALSE;
|
||||||
|
|
||||||
if (update->asynchronous)
|
if (update->asynchronous)
|
||||||
{
|
{
|
||||||
|
|
|
@ -723,6 +723,12 @@ void tls_free(rdpTls* tls)
|
||||||
if (tls->PublicKey)
|
if (tls->PublicKey)
|
||||||
free(tls->PublicKey);
|
free(tls->PublicKey);
|
||||||
|
|
||||||
|
if (tls->Bindings)
|
||||||
|
{
|
||||||
|
free(tls->Bindings->Bindings);
|
||||||
|
free(tls->Bindings);
|
||||||
|
}
|
||||||
|
|
||||||
certificate_store_free(tls->certificate_store);
|
certificate_store_free(tls->certificate_store);
|
||||||
|
|
||||||
free(tls);
|
free(tls);
|
||||||
|
|
|
@ -169,7 +169,7 @@ static int BitBlt_SRCCOPY_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWi
|
||||||
dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
|
dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
|
||||||
|
|
||||||
if (srcp != 0 && dstp != 0)
|
if (srcp != 0 && dstp != 0)
|
||||||
memcpy(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
|
memmove(dstp, srcp, nWidth * hdcDest->bytesPerPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -980,7 +980,9 @@ void gdi_free(freerdp* instance)
|
||||||
gdi_bitmap_free_ex(gdi->tile);
|
gdi_bitmap_free_ex(gdi->tile);
|
||||||
gdi_bitmap_free_ex(gdi->image);
|
gdi_bitmap_free_ex(gdi->image);
|
||||||
gdi_DeleteDC(gdi->hdc);
|
gdi_DeleteDC(gdi->hdc);
|
||||||
rfx_context_free((RFX_CONTEXT*)gdi->rfx_context);
|
rfx_context_free((RFX_CONTEXT*) gdi->rfx_context);
|
||||||
|
nsc_context_free((NSC_CONTEXT*) gdi->nsc_context);
|
||||||
|
free(gdi->clrconv->palette);
|
||||||
free(gdi->clrconv);
|
free(gdi->clrconv);
|
||||||
free(gdi);
|
free(gdi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,8 +244,8 @@ void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int heigh
|
||||||
gdi_CRgnToRect(x, y, width, height, &rect);
|
gdi_CRgnToRect(x, y, width, height, &rect);
|
||||||
|
|
||||||
brush = gdi_CreateSolidBrush(fgcolor);
|
brush = gdi_CreateSolidBrush(fgcolor);
|
||||||
|
|
||||||
gdi_FillRect(gdi->drawing->hdc, &rect, brush);
|
gdi_FillRect(gdi->drawing->hdc, &rect, brush);
|
||||||
|
gdi_DeleteObject((HGDIOBJECT) brush);
|
||||||
|
|
||||||
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
|
gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue