add NULL pointer check and set freed pointers to NULL afterward

This commit is contained in:
weizhenwei 2017-06-22 17:53:51 +08:00
parent fa1c65b656
commit 61b24bf0b3
4 changed files with 63 additions and 12 deletions

View File

@ -868,7 +868,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
out_error:
MessageQueue_Free(drive->IrpQueue);
ListDictionary_Free(drive->files);
free(drive->path);
drive_free(drive);
free(drive);
return error;
}

View File

@ -97,9 +97,26 @@ UINT rail_send_channel_data(railPlugin* rail, void* data, size_t length)
*/
static void rail_client_clean_exec_order(RAIL_EXEC_ORDER* exec)
{
free(exec->exeOrFile.string);
free(exec->workingDir.string);
free(exec->arguments.string);
if (!exec)
return;
if (exec->exeOrFile.string)
{
free(exec->exeOrFile.string);
exec->exeOrFile.string = NULL;
}
if (exec->workingDir.string)
{
free(exec->workingDir.string);
exec->workingDir.string = NULL;
}
if (exec->arguments.string)
{
free(exec->arguments.string);
exec->arguments.string = NULL;
}
}
/**

View File

@ -2041,11 +2041,28 @@ 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)
static void update_free_window_state(WINDOW_STATE_ORDER* window_state)
{
free(window_state.titleInfo.string);
free(window_state.windowRects);
free(window_state.visibilityRects);
if (!window_state)
return;
if (window_state->titleInfo.string)
{
free(window_state->titleInfo.string);
window_state->titleInfo.string = NULL;
}
if (window_state->windowRects)
{
free(window_state->windowRects);
window_state->windowRects = NULL;
}
if (window_state->visibilityRects)
{
free(window_state->visibilityRects);
window_state->visibilityRects = NULL;
}
}
rdpUpdate* update_new(rdpRdp* rdp)
@ -2147,10 +2164,11 @@ void update_free(rdpUpdate* update)
free(update->secondary);
free(update->altsec);
free(update->window->monitored_desktop.windowIds);
update_free_window_state(update->window->window_state);
update_free_window_state(&update->window->window_state);
if (update->window->window_icon.iconInfo)
{
update_free_window_icon_info(update->window->window_icon.iconInfo);
update->window->window_icon.iconInfo = NULL;
}
free(update->window);
MessageQueue_Free(update->queue);

View File

@ -364,6 +364,7 @@ BOOL update_read_window_icon_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WIN
if (window_icon->iconInfo)
{
update_free_window_icon_info(window_icon->iconInfo);
window_icon->iconInfo = NULL;
}
window_icon->iconInfo = (ICON_INFO*) calloc(1, sizeof(ICON_INFO));
@ -599,9 +600,24 @@ BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_
void update_free_window_icon_info(ICON_INFO* iconInfo)
{
free(iconInfo->bitsColor);
free(iconInfo->bitsMask);
free(iconInfo->colorTable);
if (iconInfo->bitsColor)
{
free(iconInfo->bitsColor);
iconInfo->bitsColor = NULL;
}
if (iconInfo->bitsMask)
{
free(iconInfo->bitsMask);
iconInfo->bitsMask = NULL;
}
if (iconInfo->colorTable)
{
free(iconInfo->colorTable);
iconInfo->colorTable = NULL;
}
free(iconInfo);
}