mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #4013 from weizhenwei/master
fix FreeRDP some memory leak problem
This commit is contained in:
@@ -757,6 +757,7 @@ static UINT drive_free(DEVICE* device)
|
||||
ListDictionary_Free(drive->files);
|
||||
MessageQueue_Free(drive->IrpQueue);
|
||||
Stream_Free(drive->device.data, TRUE);
|
||||
free(drive->path);
|
||||
free(drive);
|
||||
return error;
|
||||
}
|
||||
@@ -865,9 +866,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
out_error:
|
||||
MessageQueue_Free(drive->IrpQueue);
|
||||
ListDictionary_Free(drive->files);
|
||||
free(drive);
|
||||
drive_free(drive);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,25 @@ UINT rail_send_channel_data(railPlugin* rail, void* data, size_t length)
|
||||
return rail_send(rail, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* used by rail_client_execute() to free RAIL_EXEC_ORDER's
|
||||
* internal malloced memory;
|
||||
*/
|
||||
static void rail_client_clean_exec_order(RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
if (!exec)
|
||||
return;
|
||||
|
||||
free(exec->exeOrFile.string);
|
||||
exec->exeOrFile.string = NULL;
|
||||
|
||||
free(exec->workingDir.string);
|
||||
exec->workingDir.string = NULL;
|
||||
|
||||
free(exec->arguments.string);
|
||||
exec->arguments.string = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback Interface
|
||||
*/
|
||||
@@ -104,6 +123,7 @@ static UINT rail_client_execute(RailClientContext* context,
|
||||
RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
char* exeOrFile;
|
||||
UINT error;
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
exeOrFile = exec->RemoteApplicationProgram;
|
||||
|
||||
@@ -122,7 +142,9 @@ static UINT rail_client_execute(RailClientContext* context,
|
||||
&exec->workingDir); /* ShellWorkingDirectory */
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationArguments,
|
||||
&exec->arguments); /* RemoteApplicationCmdLine */
|
||||
return rail_send_client_exec_order(rail, exec);
|
||||
error = rail_send_client_exec_order(rail, exec);
|
||||
rail_client_clean_exec_order(exec);
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -614,7 +636,9 @@ static void* rail_virtual_channel_client_thread(void* arg)
|
||||
{
|
||||
data = (wStream*) message.wParam;
|
||||
|
||||
if ((error = rail_order_recv(rail, data)))
|
||||
error = rail_order_recv(rail, data);
|
||||
Stream_Free(data, TRUE);
|
||||
if (error)
|
||||
{
|
||||
WLog_ERR(TAG, "rail_order_recv failed with error %"PRIu32"!", error);
|
||||
break;
|
||||
|
||||
@@ -650,7 +650,9 @@ UINT rail_order_recv(railPlugin* rail, wStream* s)
|
||||
case RDP_RAIL_ORDER_EXEC_RESULT:
|
||||
{
|
||||
RAIL_EXEC_RESULT_ORDER execResult;
|
||||
return rail_recv_exec_result_order(rail, &execResult, s);
|
||||
error = rail_recv_exec_result_order(rail, &execResult, s);
|
||||
free(execResult.exeOrFile.string);
|
||||
return error;
|
||||
}
|
||||
|
||||
case RDP_RAIL_ORDER_SYSPARAM:
|
||||
|
||||
@@ -226,6 +226,7 @@ void xf_rail_invalidate_region(xfContext* xfc, REGION16* invalidRegion)
|
||||
}
|
||||
}
|
||||
|
||||
free(pKeys);
|
||||
region16_uninit(&windowInvalidRegion);
|
||||
}
|
||||
|
||||
|
||||
2
libfreerdp/cache/offscreen.c
vendored
2
libfreerdp/cache/offscreen.c
vendored
@@ -155,7 +155,7 @@ void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index)
|
||||
prevBitmap = offscreenCache->entries[index];
|
||||
|
||||
if (prevBitmap != NULL)
|
||||
prevBitmap->Free(offscreenCache->update->context, prevBitmap);
|
||||
Bitmap_Free(offscreenCache->update->context, prevBitmap);
|
||||
|
||||
offscreenCache->entries[index] = NULL;
|
||||
}
|
||||
|
||||
@@ -2041,6 +2041,21 @@ static void update_free_queued_message(void* obj)
|
||||
update_message_queue_free_message(msg);
|
||||
}
|
||||
|
||||
static void update_free_window_state(WINDOW_STATE_ORDER* window_state)
|
||||
{
|
||||
if (!window_state)
|
||||
return;
|
||||
|
||||
free(window_state->titleInfo.string);
|
||||
window_state->titleInfo.string = NULL;
|
||||
|
||||
free(window_state->windowRects);
|
||||
window_state->windowRects = NULL;
|
||||
|
||||
free(window_state->visibilityRects);
|
||||
window_state->visibilityRects = NULL;
|
||||
}
|
||||
|
||||
rdpUpdate* update_new(rdpRdp* rdp)
|
||||
{
|
||||
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
|
||||
@@ -2139,6 +2154,9 @@ void update_free(rdpUpdate* update)
|
||||
free(update->primary);
|
||||
free(update->secondary);
|
||||
free(update->altsec);
|
||||
free(update->window->monitored_desktop.windowIds);
|
||||
update_free_window_state(&update->window->window_state);
|
||||
update_free_window_icon_info(update->window->window_icon.iconInfo);
|
||||
free(update->window);
|
||||
MessageQueue_Free(update->queue);
|
||||
free(update);
|
||||
|
||||
@@ -194,6 +194,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
{
|
||||
int i;
|
||||
int size;
|
||||
RECTANGLE_16* newRect;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
|
||||
{
|
||||
@@ -295,9 +296,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
Stream_Read_UINT16(s, windowState->numWindowRects); /* numWindowRects (2 bytes) */
|
||||
|
||||
size = sizeof(RECTANGLE_16) * windowState->numWindowRects;
|
||||
windowState->windowRects = (RECTANGLE_16*) malloc(size);
|
||||
if (!windowState->windowRects)
|
||||
newRect = (RECTANGLE_16*)realloc(windowState->windowRects, size);
|
||||
if (!newRect)
|
||||
{
|
||||
free(windowState->windowRects);
|
||||
windowState->windowRects = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
windowState->windowRects = newRect;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 8 * windowState->numWindowRects)
|
||||
return FALSE;
|
||||
@@ -329,9 +335,14 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
Stream_Read_UINT16(s, windowState->numVisibilityRects); /* numVisibilityRects (2 bytes) */
|
||||
|
||||
size = sizeof(RECTANGLE_16) * windowState->numVisibilityRects;
|
||||
windowState->visibilityRects = (RECTANGLE_16*) malloc(size);
|
||||
if (!windowState->visibilityRects)
|
||||
newRect = (RECTANGLE_16*)realloc(windowState->visibilityRects, size);
|
||||
if (!newRect)
|
||||
{
|
||||
free(windowState->visibilityRects);
|
||||
windowState->visibilityRects = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
windowState->visibilityRects = newRect;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < windowState->numVisibilityRects * 8)
|
||||
return FALSE;
|
||||
@@ -350,6 +361,7 @@ BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WI
|
||||
|
||||
BOOL update_read_window_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon)
|
||||
{
|
||||
update_free_window_icon_info(window_icon->iconInfo);
|
||||
window_icon->iconInfo = (ICON_INFO*) calloc(1, sizeof(ICON_INFO));
|
||||
if (!window_icon->iconInfo)
|
||||
return FALSE;
|
||||
@@ -581,6 +593,23 @@ BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_
|
||||
return result;
|
||||
}
|
||||
|
||||
void update_free_window_icon_info(ICON_INFO* iconInfo)
|
||||
{
|
||||
if (!iconInfo)
|
||||
return;
|
||||
|
||||
free(iconInfo->bitsColor);
|
||||
iconInfo->bitsColor = NULL;
|
||||
|
||||
free(iconInfo->bitsMask);
|
||||
iconInfo->bitsMask = NULL;
|
||||
|
||||
free(iconInfo->colorTable);
|
||||
iconInfo->colorTable = NULL;
|
||||
|
||||
free(iconInfo);
|
||||
}
|
||||
|
||||
BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s)
|
||||
{
|
||||
UINT16 orderSize;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/api.h>
|
||||
|
||||
FREERDP_LOCAL void update_free_window_icon_info(ICON_INFO* iconInfo);
|
||||
FREERDP_LOCAL BOOL update_recv_altsec_window_order(rdpUpdate* update,
|
||||
wStream* s);
|
||||
|
||||
|
||||
@@ -933,11 +933,13 @@ HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
|
||||
if (!ConvertFindDataAToW(fd, lpFindFileData))
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
free(fd);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
h = INVALID_HANDLE_VALUE;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
free(fd);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user