freerdp: patch valgrind leaks, cleanup
This commit is contained in:
parent
01ac15a879
commit
fdd2dc7601
@ -409,6 +409,8 @@ static void cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
|
||||
WLog_ERR(TAG, "unknown msgType %d", msgType);
|
||||
break;
|
||||
}
|
||||
|
||||
Stream_Free(s, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -890,6 +892,8 @@ static void cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
|
||||
|
||||
cliprdr_remove_open_handle_data(cliprdr->OpenHandle);
|
||||
cliprdr_remove_init_handle_data(cliprdr->InitHandle);
|
||||
|
||||
free(cliprdr);
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
|
||||
|
@ -620,6 +620,9 @@ static void drive_free(DEVICE* device)
|
||||
CloseHandle(drive->thread);
|
||||
|
||||
ListDictionary_Free(drive->files);
|
||||
MessageQueue_Free(drive->IrpQueue);
|
||||
|
||||
Stream_Free(drive->device.data, TRUE);
|
||||
|
||||
free(drive);
|
||||
}
|
||||
|
@ -999,6 +999,8 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
|
||||
|
||||
rdpdr_remove_open_handle_data(rdpdr->OpenHandle);
|
||||
rdpdr_remove_init_handle_data(rdpdr->InitHandle);
|
||||
|
||||
free(rdpdr);
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
|
||||
|
@ -1010,6 +1010,8 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||
rdpsnd->data_in = NULL;
|
||||
}
|
||||
|
||||
MessagePipe_Free(rdpsnd->MsgPipe);
|
||||
|
||||
if (rdpsnd->device)
|
||||
IFCALL(rdpsnd->device->Free, rdpsnd->device);
|
||||
|
||||
@ -1029,6 +1031,8 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||
|
||||
rdpsnd_remove_open_handle_data(rdpsnd->OpenHandle);
|
||||
rdpsnd_remove_init_handle_data(rdpsnd->InitHandle);
|
||||
|
||||
free(rdpsnd);
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength)
|
||||
@ -1065,12 +1069,10 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
rdpsndPlugin* rdpsnd;
|
||||
|
||||
rdpsnd = (rdpsndPlugin*) malloc(sizeof(rdpsndPlugin));
|
||||
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
|
||||
|
||||
if (rdpsnd)
|
||||
{
|
||||
ZeroMemory(rdpsnd, sizeof(rdpsndPlugin));
|
||||
|
||||
#if !defined(_WIN32) && !defined(ANDROID)
|
||||
{
|
||||
sigset_t mask;
|
||||
|
@ -1142,6 +1142,12 @@ void xf_clipboard_free(xfClipboard* clipboard)
|
||||
clipboard->serverFormats = NULL;
|
||||
}
|
||||
|
||||
if (clipboard->numClientFormats)
|
||||
{
|
||||
for (i = 0; i < clipboard->numClientFormats; i++)
|
||||
free(clipboard->clientFormats[i].formatName);
|
||||
}
|
||||
|
||||
ClipboardDestroy(clipboard->system);
|
||||
|
||||
free(clipboard->data);
|
||||
|
@ -43,7 +43,6 @@ FREERDP_API int freerdp_channels_post_connect(rdpChannels* channels, freerdp* in
|
||||
FREERDP_API BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** read_fds,
|
||||
int* read_count, void** write_fds, int* write_count);
|
||||
FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance);
|
||||
FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels);
|
||||
FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance);
|
||||
|
||||
FREERDP_API void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name);
|
||||
|
17
libfreerdp/cache/glyph.c
vendored
17
libfreerdp/cache/glyph.c
vendored
@ -150,7 +150,7 @@ void update_process_glyph_fragments(rdpContext* context, BYTE* data, UINT32 leng
|
||||
size = data[index + 2];
|
||||
|
||||
fragments = (BYTE*) malloc(size);
|
||||
memcpy(fragments, data, size);
|
||||
CopyMemory(fragments, data, size);
|
||||
glyph_cache_fragment_put(glyph_cache, id, size, fragments);
|
||||
|
||||
index += 3;
|
||||
@ -494,14 +494,12 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings)
|
||||
{
|
||||
rdpGlyphCache* glyphCache;
|
||||
|
||||
glyphCache = (rdpGlyphCache*) malloc(sizeof(rdpGlyphCache));
|
||||
glyphCache = (rdpGlyphCache*) calloc(1, sizeof(rdpGlyphCache));
|
||||
|
||||
if (glyphCache)
|
||||
{
|
||||
int i;
|
||||
|
||||
ZeroMemory(glyphCache, sizeof(rdpGlyphCache));
|
||||
|
||||
WLog_Init();
|
||||
glyphCache->log = WLog_Get("com.freerdp.cache.glyph");
|
||||
|
||||
@ -512,12 +510,10 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings)
|
||||
{
|
||||
glyphCache->glyphCache[i].number = settings->GlyphCache[i].cacheEntries;
|
||||
glyphCache->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize;
|
||||
glyphCache->glyphCache[i].entries = (rdpGlyph**) malloc(sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number);
|
||||
ZeroMemory(glyphCache->glyphCache[i].entries, sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number);
|
||||
glyphCache->glyphCache[i].entries = (rdpGlyph**) calloc(glyphCache->glyphCache[i].number, sizeof(rdpGlyph*));
|
||||
}
|
||||
|
||||
glyphCache->fragCache.entries = malloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256);
|
||||
ZeroMemory(glyphCache->fragCache.entries, sizeof(FRAGMENT_CACHE_ENTRY) * 256);
|
||||
glyphCache->fragCache.entries = calloc(256, sizeof(FRAGMENT_CACHE_ENTRY));
|
||||
}
|
||||
|
||||
return glyphCache;
|
||||
@ -555,10 +551,9 @@ void glyph_cache_free(rdpGlyphCache* glyphCache)
|
||||
glyphCache->glyphCache[i].entries = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 255; i++)
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
fragment = glyphCache->fragCache.entries[i].fragment;
|
||||
free(fragment);
|
||||
free(glyphCache->fragCache.entries[i].fragment);
|
||||
glyphCache->fragCache.entries[i].fragment = NULL;
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,22 @@ rdpChannels* freerdp_channels_new(void)
|
||||
|
||||
void freerdp_channels_free(rdpChannels* channels)
|
||||
{
|
||||
int index;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
|
||||
MessagePipe_Free(channels->MsgPipe);
|
||||
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
pChannelOpenData = &channels->openDataList[index];
|
||||
|
||||
if (pChannelOpenData->pInterface)
|
||||
{
|
||||
free(pChannelOpenData->pInterface);
|
||||
pChannelOpenData->pInterface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free(channels);
|
||||
}
|
||||
|
||||
@ -265,7 +279,6 @@ static int freerdp_channels_process_sync(rdpChannels* channels, freerdp* instanc
|
||||
{
|
||||
int status = TRUE;
|
||||
wMessage message;
|
||||
wMessage* event;
|
||||
rdpMcsChannel* channel;
|
||||
CHANNEL_OPEN_EVENT* item;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
@ -302,8 +315,6 @@ static int freerdp_channels_process_sync(rdpChannels* channels, freerdp* instanc
|
||||
}
|
||||
else if (message.id == 1)
|
||||
{
|
||||
event = (wMessage*) message.wParam;
|
||||
|
||||
/**
|
||||
* Ignore for now, the same event is being pushed on the In queue,
|
||||
* and we're pushing it on the Out queue just to wake other threads
|
||||
@ -384,22 +395,6 @@ BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wMessage* freerdp_channels_pop_event(rdpChannels* channels)
|
||||
{
|
||||
wMessage message;
|
||||
wMessage* event = NULL;
|
||||
|
||||
if (MessageQueue_Peek(channels->MsgPipe->In, &message, TRUE))
|
||||
{
|
||||
if (message.id == 1)
|
||||
{
|
||||
event = (wMessage*) message.wParam;
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
|
||||
{
|
||||
int index;
|
||||
|
@ -1623,47 +1623,46 @@ BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph)
|
||||
BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fastGlyph)
|
||||
{
|
||||
BYTE* phold;
|
||||
GLYPH_DATA_V2* glyph;
|
||||
GLYPH_DATA_V2* glyph = &fastGlyph->glyphData;
|
||||
|
||||
ORDER_FIELD_BYTE(1, fast_glyph->cacheId);
|
||||
ORDER_FIELD_2BYTE(2, fast_glyph->ulCharInc, fast_glyph->flAccel);
|
||||
ORDER_FIELD_COLOR(3, fast_glyph->backColor);
|
||||
ORDER_FIELD_COLOR(4, fast_glyph->foreColor);
|
||||
ORDER_FIELD_COORD(5, fast_glyph->bkLeft);
|
||||
ORDER_FIELD_COORD(6, fast_glyph->bkTop);
|
||||
ORDER_FIELD_COORD(7, fast_glyph->bkRight);
|
||||
ORDER_FIELD_COORD(8, fast_glyph->bkBottom);
|
||||
ORDER_FIELD_COORD(9, fast_glyph->opLeft);
|
||||
ORDER_FIELD_COORD(10, fast_glyph->opTop);
|
||||
ORDER_FIELD_COORD(11, fast_glyph->opRight);
|
||||
ORDER_FIELD_COORD(12, fast_glyph->opBottom);
|
||||
ORDER_FIELD_COORD(13, fast_glyph->x);
|
||||
ORDER_FIELD_COORD(14, fast_glyph->y);
|
||||
ORDER_FIELD_BYTE(1, fastGlyph->cacheId);
|
||||
ORDER_FIELD_2BYTE(2, fastGlyph->ulCharInc, fastGlyph->flAccel);
|
||||
ORDER_FIELD_COLOR(3, fastGlyph->backColor);
|
||||
ORDER_FIELD_COLOR(4, fastGlyph->foreColor);
|
||||
ORDER_FIELD_COORD(5, fastGlyph->bkLeft);
|
||||
ORDER_FIELD_COORD(6, fastGlyph->bkTop);
|
||||
ORDER_FIELD_COORD(7, fastGlyph->bkRight);
|
||||
ORDER_FIELD_COORD(8, fastGlyph->bkBottom);
|
||||
ORDER_FIELD_COORD(9, fastGlyph->opLeft);
|
||||
ORDER_FIELD_COORD(10, fastGlyph->opTop);
|
||||
ORDER_FIELD_COORD(11, fastGlyph->opRight);
|
||||
ORDER_FIELD_COORD(12, fastGlyph->opBottom);
|
||||
ORDER_FIELD_COORD(13, fastGlyph->x);
|
||||
ORDER_FIELD_COORD(14, fastGlyph->y);
|
||||
|
||||
if (orderInfo->fieldFlags & ORDER_FIELD_15)
|
||||
{
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT8(s, fast_glyph->cbData);
|
||||
Stream_Read_UINT8(s, fastGlyph->cbData);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < fast_glyph->cbData)
|
||||
if (Stream_GetRemainingLength(s) < fastGlyph->cbData)
|
||||
return FALSE;
|
||||
|
||||
CopyMemory(fast_glyph->data, Stream_Pointer(s), fast_glyph->cbData);
|
||||
CopyMemory(fastGlyph->data, Stream_Pointer(s), fastGlyph->cbData);
|
||||
phold = Stream_Pointer(s);
|
||||
|
||||
if (!Stream_SafeSeek(s, 1))
|
||||
return FALSE;
|
||||
|
||||
if (fast_glyph->cbData > 1)
|
||||
if (fastGlyph->cbData > 1)
|
||||
{
|
||||
/* parse optional glyph data */
|
||||
glyph = &fast_glyph->glyphData;
|
||||
glyph->cacheIndex = fast_glyph->data[0];
|
||||
glyph->cacheIndex = fastGlyph->data[0];
|
||||
|
||||
if (!update_read_2byte_signed(s, &glyph->x) ||
|
||||
!update_read_2byte_signed(s, &glyph->y) ||
|
||||
@ -1677,17 +1676,14 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
|
||||
if (Stream_GetRemainingLength(s) < glyph->cb)
|
||||
return FALSE;
|
||||
|
||||
if (glyph->aj)
|
||||
if (glyph->cb)
|
||||
{
|
||||
free(glyph->aj);
|
||||
glyph->aj = NULL;
|
||||
glyph->aj = (BYTE*) realloc(glyph->aj, glyph->cb);
|
||||
Stream_Read(s, glyph->aj, glyph->cb);
|
||||
}
|
||||
|
||||
glyph->aj = (BYTE*) malloc(glyph->cb);
|
||||
Stream_Read(s, glyph->aj, glyph->cb);
|
||||
}
|
||||
|
||||
Stream_Pointer(s) = phold + fast_glyph->cbData;
|
||||
Stream_Pointer(s) = phold + fastGlyph->cbData;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -526,6 +526,12 @@ void update_reset_state(rdpUpdate* update)
|
||||
rdpPrimaryUpdate* primary = update->primary;
|
||||
rdpAltSecUpdate* altsec = update->altsec;
|
||||
|
||||
if (primary->fast_glyph.glyphData.aj)
|
||||
{
|
||||
free(primary->fast_glyph.glyphData.aj);
|
||||
primary->fast_glyph.glyphData.aj = NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(&primary->order_info, sizeof(ORDER_INFO));
|
||||
ZeroMemory(&primary->dstblt, sizeof(DSTBLT_ORDER));
|
||||
ZeroMemory(&primary->patblt, sizeof(PATBLT_ORDER));
|
||||
@ -1707,35 +1713,27 @@ rdpUpdate* update_new(rdpRdp* rdp)
|
||||
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
|
||||
rdpUpdate* update;
|
||||
|
||||
update = (rdpUpdate*) malloc(sizeof(rdpUpdate));
|
||||
update = (rdpUpdate*) calloc(1, sizeof(rdpUpdate));
|
||||
|
||||
if (update)
|
||||
{
|
||||
OFFSCREEN_DELETE_LIST* deleteList;
|
||||
|
||||
ZeroMemory(update, sizeof(rdpUpdate));
|
||||
|
||||
WLog_Init();
|
||||
update->log = WLog_Get("com.freerdp.core.update");
|
||||
|
||||
update->bitmap_update.count = 64;
|
||||
update->bitmap_update.rectangles = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * update->bitmap_update.count);
|
||||
ZeroMemory(update->bitmap_update.rectangles, sizeof(BITMAP_DATA) * update->bitmap_update.count);
|
||||
update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(update->bitmap_update.count, sizeof(BITMAP_DATA));
|
||||
|
||||
update->pointer = (rdpPointerUpdate*) malloc(sizeof(rdpPointerUpdate));
|
||||
ZeroMemory(update->pointer, sizeof(rdpPointerUpdate));
|
||||
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
|
||||
|
||||
update->primary = (rdpPrimaryUpdate*) malloc(sizeof(rdpPrimaryUpdate));
|
||||
ZeroMemory(update->primary, sizeof(rdpPrimaryUpdate));
|
||||
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
|
||||
|
||||
update->secondary = (rdpSecondaryUpdate*) malloc(sizeof(rdpSecondaryUpdate));
|
||||
ZeroMemory(update->secondary, sizeof(rdpSecondaryUpdate));
|
||||
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
|
||||
|
||||
update->altsec = (rdpAltSecUpdate*) malloc(sizeof(rdpAltSecUpdate));
|
||||
ZeroMemory(update->altsec, sizeof(rdpAltSecUpdate));
|
||||
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
|
||||
|
||||
update->window = (rdpWindowUpdate*) malloc(sizeof(rdpWindowUpdate));
|
||||
ZeroMemory(update->window, sizeof(rdpWindowUpdate));
|
||||
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
|
||||
|
||||
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
|
||||
deleteList->sIndices = 64;
|
||||
|
Loading…
Reference in New Issue
Block a user