free can handle NULL perfectly fine

This commit is contained in:
Norbert Federa 2015-05-11 09:07:39 +02:00
parent d4df3a952b
commit 1eff1a345e
97 changed files with 256 additions and 624 deletions

View File

@ -366,7 +366,6 @@ static void audin_alsa_close(IAudinDevice* device)
alsa->thread = NULL; alsa->thread = NULL;
} }
if (alsa->buffer)
free(alsa->buffer); free(alsa->buffer);
alsa->buffer = NULL; alsa->buffer = NULL;

View File

@ -475,17 +475,13 @@ static BOOL audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDI
void audin_set_subsystem(AUDIN_PLUGIN* audin, char* subsystem) void audin_set_subsystem(AUDIN_PLUGIN* audin, char* subsystem)
{ {
if (audin->subsystem)
free(audin->subsystem); free(audin->subsystem);
audin->subsystem = _strdup(subsystem); audin->subsystem = _strdup(subsystem);
} }
void audin_set_device_name(AUDIN_PLUGIN* audin, char* device_name) void audin_set_device_name(AUDIN_PLUGIN* audin, char* device_name)
{ {
if (audin->device_name)
free(audin->device_name); free(audin->device_name);
audin->device_name = _strdup(device_name); audin->device_name = _strdup(device_name);
} }

View File

@ -154,7 +154,6 @@ static void audin_opensles_free(IAudinDevice* device)
freerdp_dsp_context_free(opensles->dsp_context); freerdp_dsp_context_free(opensles->dsp_context);
if (opensles->device_name)
free(opensles->device_name); free(opensles->device_name);
free(opensles); free(opensles);

View File

@ -492,8 +492,6 @@ void audin_server_context_free(audin_server_context* context)
if (audin->dsp_context) if (audin->dsp_context)
freerdp_dsp_context_free(audin->dsp_context); freerdp_dsp_context_free(audin->dsp_context);
if (audin->context.client_formats)
free(audin->context.client_formats); free(audin->context.client_formats);
free(audin); free(audin);
} }

View File

@ -629,7 +629,6 @@ static int cliprdr_server_receive_format_list(CliprdrServerContext* context, wSt
for (index = 0; index < formatList.numFormats; index++) for (index = 0; index < formatList.numFormats; index++)
{ {
if (formatList.formats[index].formatName)
free(formatList.formats[index].formatName); free(formatList.formats[index].formatName);
} }

View File

@ -212,10 +212,7 @@ static int disp_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{ {
DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*) pChannelCallback; DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*) pChannelCallback;
if (callback)
{
free(callback); free(callback);
}
return 0; return 0;
} }
@ -270,10 +267,7 @@ static int disp_plugin_terminated(IWTSPlugin* pPlugin)
{ {
DISP_PLUGIN* disp = (DISP_PLUGIN*) pPlugin; DISP_PLUGIN* disp = (DISP_PLUGIN*) pPlugin;
if (disp)
{
free(disp); free(disp);
}
return 0; return 0;
} }

View File

@ -131,12 +131,8 @@ DrdynvcServerContext* drdynvc_server_context_new(HANDLE vcm)
void drdynvc_server_context_free(DrdynvcServerContext* context) void drdynvc_server_context_free(DrdynvcServerContext* context)
{ {
if (context) if (context)
{
if (context->priv)
{ {
free(context->priv); free(context->priv);
}
free(context); free(context);
} }
} }

View File

@ -126,10 +126,7 @@ static int echo_plugin_terminated(IWTSPlugin* pPlugin)
{ {
ECHO_PLUGIN* echo = (ECHO_PLUGIN*) pPlugin; ECHO_PLUGIN* echo = (ECHO_PLUGIN*) pPlugin;
if (echo)
{
free(echo); free(echo);
}
return 0; return 0;
} }

View File

@ -262,12 +262,8 @@ EncomspServerContext* encomsp_server_context_new(HANDLE vcm)
void encomsp_server_context_free(EncomspServerContext* context) void encomsp_server_context_free(EncomspServerContext* context)
{ {
if (context) if (context)
{
if (context->priv)
{ {
free(context->priv); free(context->priv);
}
free(context); free(context);
} }
} }

View File

@ -54,7 +54,6 @@ void rail_string_to_unicode_string(char* string, RAIL_UNICODE_STRING* unicode_st
WCHAR* buffer = NULL; WCHAR* buffer = NULL;
int length = 0; int length = 0;
if (unicode_string->string != NULL)
free(unicode_string->string); free(unicode_string->string);
unicode_string->string = NULL; unicode_string->string = NULL;

View File

@ -669,7 +669,6 @@ static void rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr, BOOL use
} }
} }
if (pKeys)
free(pKeys); free(pKeys);
pos = (int) Stream_GetPosition(s); pos = (int) Stream_GetPosition(s);

View File

@ -620,12 +620,8 @@ RdpdrServerContext* rdpdr_server_context_new(HANDLE vcm)
void rdpdr_server_context_free(RdpdrServerContext* context) void rdpdr_server_context_free(RdpdrServerContext* context)
{ {
if (context) if (context)
{
if (context->priv)
{ {
free(context->priv); free(context->priv);
}
free(context); free(context);
} }
} }

View File

@ -533,11 +533,8 @@ static int rdpei_plugin_terminated(IWTSPlugin* pPlugin)
DeleteCriticalSection(&rdpei->lock); DeleteCriticalSection(&rdpei->lock);
if (rdpei->listener_callback)
free(rdpei->listener_callback); free(rdpei->listener_callback);
free(rdpei->context); free(rdpei->context);
free(rdpei); free(rdpei);
return 0; return 0;

View File

@ -123,9 +123,7 @@ int rdpgfx_decode_h264(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
if (status < 0) if (status < 0)
{ {
if (h264.meta.regionRects)
free(h264.meta.regionRects); free(h264.meta.regionRects);
if (h264.meta.quantQualityVals)
free(h264.meta.quantQualityVals); free(h264.meta.quantQualityVals);
return -1; return -1;
} }

View File

@ -617,17 +617,13 @@ static BOOL rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, AD
void rdpsnd_set_subsystem(rdpsndPlugin* rdpsnd, char* subsystem) void rdpsnd_set_subsystem(rdpsndPlugin* rdpsnd, char* subsystem)
{ {
if (rdpsnd->subsystem)
free(rdpsnd->subsystem); free(rdpsnd->subsystem);
rdpsnd->subsystem = _strdup(subsystem); rdpsnd->subsystem = _strdup(subsystem);
} }
void rdpsnd_set_device_name(rdpsndPlugin* rdpsnd, char* device_name) void rdpsnd_set_device_name(rdpsndPlugin* rdpsnd, char* device_name)
{ {
if (rdpsnd->device_name)
free(rdpsnd->device_name); free(rdpsnd->device_name);
rdpsnd->device_name = _strdup(device_name); rdpsnd->device_name = _strdup(device_name);
} }

View File

@ -130,7 +130,6 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO
winmm->device.WaveConfirm(&(winmm->device), wave); winmm->device.WaveConfirm(&(winmm->device), wave);
if (lpWaveHdr->lpData)
free(lpWaveHdr->lpData); free(lpWaveHdr->lpData);
free(wave); free(wave);

View File

@ -602,7 +602,6 @@ void rdpsnd_server_context_free(RdpsndServerContext* context)
if (context->priv->ChannelHandle) if (context->priv->ChannelHandle)
WTSVirtualChannelClose(context->priv->ChannelHandle); WTSVirtualChannelClose(context->priv->ChannelHandle);
if (context->priv->out_buffer)
free(context->priv->out_buffer); free(context->priv->out_buffer);
if (context->priv->dsp_context) if (context->priv->dsp_context)
@ -611,7 +610,6 @@ void rdpsnd_server_context_free(RdpsndServerContext* context)
if (context->priv->input_stream) if (context->priv->input_stream)
Stream_Free(context->priv->input_stream, TRUE); Stream_Free(context->priv->input_stream, TRUE);
if (context->client_formats)
free(context->client_formats); free(context->client_formats);
free(context); free(context);

View File

@ -539,12 +539,8 @@ RemdeskServerContext* remdesk_server_context_new(HANDLE vcm)
void remdesk_server_context_free(RemdeskServerContext* context) void remdesk_server_context_free(RemdeskServerContext* context)
{ {
if (context) if (context)
{
if (context->priv)
{ {
free(context->priv); free(context->priv);
}
free(context); free(context);
} }
} }

View File

@ -277,7 +277,6 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
Stream_Write(irp->output, buffer, nbRead); /* ReadData */ Stream_Write(irp->output, buffer, nbRead); /* ReadData */
} }
if (buffer)
free(buffer); free(buffer);
} }
@ -389,10 +388,7 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
/* Stream_Write_UINT8(irp->output, 0); /\* Padding (1 byte) *\/ */ /* Stream_Write_UINT8(irp->output, 0); /\* Padding (1 byte) *\/ */
/* } */ /* } */
if (InputBuffer != NULL)
free(InputBuffer); free(InputBuffer);
if (OutputBuffer != NULL)
free(OutputBuffer); free(OutputBuffer);
} }
@ -620,7 +616,6 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
irp->IoStatus = STATUS_NO_MEMORY; irp->IoStatus = STATUS_NO_MEMORY;
irp->Complete(irp); irp->Complete(irp);
if (data)
free(data); free(data);
} }

View File

@ -443,9 +443,7 @@ static UINT32 smartcard_GetStatusChangeA_Call(SMARTCARD_DEVICE* smartcard, SMART
for (index = 0; index < call->cReaders; index++) for (index = 0; index < call->cReaders; index++)
{ {
rgReaderState = &call->rgReaderStates[index]; rgReaderState = &call->rgReaderStates[index];
free(rgReaderState->szReader);
if (rgReaderState->szReader)
free((void*) rgReaderState->szReader);
} }
free(call->rgReaderStates); free(call->rgReaderStates);
@ -508,9 +506,7 @@ static UINT32 smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, SMART
for (index = 0; index < call->cReaders; index++) for (index = 0; index < call->cReaders; index++)
{ {
rgReaderState = &call->rgReaderStates[index]; rgReaderState = &call->rgReaderStates[index];
free(rgReaderState->szReader);
if (rgReaderState->szReader)
free((void*) rgReaderState->szReader);
} }
free(call->rgReaderStates); free(call->rgReaderStates);
@ -585,7 +581,6 @@ static UINT32 smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status) if (status)
return status; return status;
if (call->szReader)
free(call->szReader); free(call->szReader);
return ret.ReturnCode; return ret.ReturnCode;
@ -634,7 +629,6 @@ static UINT32 smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status) if (status)
return status; return status;
if (call->szReader)
free(call->szReader); free(call->szReader);
return ret.ReturnCode; return ret.ReturnCode;
@ -923,16 +917,9 @@ static UINT32 smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status != SCARD_S_SUCCESS) if (status != SCARD_S_SUCCESS)
return status; return status;
if (call->pbSendBuffer)
free(call->pbSendBuffer); free(call->pbSendBuffer);
if (ret.pbRecvBuffer)
free(ret.pbRecvBuffer); free(ret.pbRecvBuffer);
if (call->pioSendPci)
free(call->pioSendPci); free(call->pioSendPci);
if (call->pioRecvPci)
free(call->pioRecvPci); free(call->pioRecvPci);
return ret.ReturnCode; return ret.ReturnCode;
@ -974,10 +961,7 @@ static UINT32 smartcard_Control_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
if (status != SCARD_S_SUCCESS) if (status != SCARD_S_SUCCESS)
return status; return status;
if (call->pvInBuffer)
free(call->pvInBuffer); free(call->pvInBuffer);
if (ret.pvOutBuffer)
free(ret.pvOutBuffer); free(ret.pvOutBuffer);
return ret.ReturnCode; return ret.ReturnCode;

View File

@ -499,13 +499,14 @@ static void tsmf_ffmpeg_free(ITSMFDecoder* decoder)
TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder; TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
if (mdecoder->frame) if (mdecoder->frame)
av_free(mdecoder->frame); av_free(mdecoder->frame);
if (mdecoder->decoded_data)
free(mdecoder->decoded_data); free(mdecoder->decoded_data);
if (mdecoder->codec_context) if (mdecoder->codec_context)
{ {
if (mdecoder->prepared) if (mdecoder->prepared)
avcodec_close(mdecoder->codec_context); avcodec_close(mdecoder->codec_context);
if (mdecoder->codec_context->extradata)
free(mdecoder->codec_context->extradata); free(mdecoder->codec_context->extradata);
av_free(mdecoder->codec_context); av_free(mdecoder->codec_context);
} }

View File

@ -354,9 +354,7 @@ static int tsmf_plugin_terminated(IWTSPlugin* pPlugin)
DEBUG_TSMF(""); DEBUG_TSMF("");
if (tsmf->listener_callback)
free(tsmf->listener_callback); free(tsmf->listener_callback);
free(tsmf); free(tsmf);
return 0; return 0;

View File

@ -215,9 +215,7 @@ static void tsmf_sample_free(void *arg)
if (!sample) if (!sample)
return; return;
if (sample->data)
free(sample->data); free(sample->data);
free(sample); free(sample);
} }
@ -916,7 +914,6 @@ void _tsmf_presentation_free(TSMF_PRESENTATION* presentation)
ArrayList_Clear(presentation->stream_list); ArrayList_Clear(presentation->stream_list);
ArrayList_Free(presentation->stream_list); ArrayList_Free(presentation->stream_list);
if (presentation->rects)
free(presentation->rects); free(presentation->rects);
ZeroMemory(presentation, sizeof(TSMF_PRESENTATION)); ZeroMemory(presentation, sizeof(TSMF_PRESENTATION));

View File

@ -1026,9 +1026,7 @@ static int urbdrc_load_udevman_addin(IWTSPlugin* pPlugin, const char* name, ADDI
void urbdrc_set_subsystem(URBDRC_PLUGIN* urbdrc, char* subsystem) void urbdrc_set_subsystem(URBDRC_PLUGIN* urbdrc, char* subsystem)
{ {
if (urbdrc->subsystem)
free(urbdrc->subsystem); free(urbdrc->subsystem);
urbdrc->subsystem = _strdup(subsystem); urbdrc->subsystem = _strdup(subsystem);
} }

View File

@ -238,7 +238,6 @@ ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode)
void android_event_key_free(ANDROID_EVENT_KEY* event) void android_event_key_free(ANDROID_EVENT_KEY* event)
{ {
if (event != NULL)
free(event); free(event);
} }
@ -257,7 +256,6 @@ ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 key)
void android_event_unicodekey_free(ANDROID_EVENT_KEY* event) void android_event_unicodekey_free(ANDROID_EVENT_KEY* event)
{ {
if (event != NULL)
free(event); free(event);
} }
@ -278,7 +276,6 @@ ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y)
void android_event_cursor_free(ANDROID_EVENT_CURSOR* event) void android_event_cursor_free(ANDROID_EVENT_CURSOR* event)
{ {
if (event != NULL)
free(event); free(event);
} }
@ -295,7 +292,6 @@ ANDROID_EVENT* android_event_disconnect_new()
void android_event_disconnect_free(ANDROID_EVENT* event) void android_event_disconnect_free(ANDROID_EVENT* event)
{ {
if (event != NULL)
free(event); free(event);
} }
@ -319,12 +315,9 @@ ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(void* data, int data_length
void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event) void android_event_clipboard_free(ANDROID_EVENT_CLIPBOARD* event)
{ {
if (event != NULL) if (event)
{
if (event->data)
{ {
free(event->data); free(event->data);
}
free(event); free(event);
} }
} }

View File

@ -276,19 +276,13 @@ BOOL android_authenticate(freerdp* instance, char** username, char** password, c
if (res == JNI_TRUE) if (res == JNI_TRUE)
{ {
// read back string values // read back string values
if (*username != NULL)
free(*username); free(*username);
*username = get_string_from_string_builder(env, jstr1); *username = get_string_from_string_builder(env, jstr1);
if (*domain != NULL)
free(*domain); free(*domain);
*domain = get_string_from_string_builder(env, jstr2); *domain = get_string_from_string_builder(env, jstr2);
if (*password == NULL)
free(*password); free(*password);
*password = get_string_from_string_builder(env, jstr3); *password = get_string_from_string_builder(env, jstr3);
} }

View File

@ -231,7 +231,6 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type()
} }
} }
if (tIOHIDDeviceRefs)
free(tIOHIDDeviceRefs); free(tIOHIDDeviceRefs);
if (deviceCFSetRef) if (deviceCFSetRef)

View File

@ -693,17 +693,13 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
int i; int i;
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{
if (argv[i])
free(argv[i]); free(argv[i]);
}
if (!is_connected) if (!is_connected)
return; return;
gdi_free(context->instance); gdi_free(context->instance);
if (pixel_data)
free(pixel_data); free(pixel_data);
} }

View File

@ -305,9 +305,7 @@ void CliprdrStream_Delete(CliprdrStream* instance)
{ {
if (instance) if (instance)
{ {
if (instance->iStream.lpVtbl)
free(instance->iStream.lpVtbl); free(instance->iStream.lpVtbl);
free(instance); free(instance);
} }
} }
@ -596,13 +594,8 @@ void CliprdrDataObject_Delete(CliprdrDataObject* instance)
{ {
if (instance) if (instance)
{ {
if (instance->iDataObject.lpVtbl)
free(instance->iDataObject.lpVtbl); free(instance->iDataObject.lpVtbl);
if (instance->m_pFormatEtc)
free(instance->m_pFormatEtc); free(instance->m_pFormatEtc);
if (instance->m_pStgMedium)
free(instance->m_pStgMedium); free(instance->m_pStgMedium);
if (instance->m_pStream) if (instance->m_pStream)
@ -837,7 +830,6 @@ void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance)
if (instance) if (instance)
{ {
if (instance->iEnumFORMATETC.lpVtbl)
free(instance->iEnumFORMATETC.lpVtbl); free(instance->iEnumFORMATETC.lpVtbl);
if (instance->m_pFormatEtc) if (instance->m_pFormatEtc)
@ -932,13 +924,10 @@ static void clear_format_map(wfClipboard* clipboard)
map->remote_format_id = 0; map->remote_format_id = 0;
map->local_format_id = 0; map->local_format_id = 0;
if (map->name)
{
free(map->name); free(map->name);
map->name = NULL; map->name = NULL;
} }
} }
}
clipboard->map_size = 0; clipboard->map_size = 0;
} }
@ -1254,27 +1243,21 @@ static void clear_file_array(wfClipboard* clipboard)
if (clipboard->file_names) if (clipboard->file_names)
{ {
for (i = 0; i < clipboard->nFiles; i++) for (i = 0; i < clipboard->nFiles; i++)
{
if (clipboard->file_names[i])
{ {
free(clipboard->file_names[i]); free(clipboard->file_names[i]);
clipboard->file_names[i] = NULL; clipboard->file_names[i] = NULL;
} }
} }
}
/* clear fileDescriptor array */ /* clear fileDescriptor array */
if (clipboard->fileDescriptor) if (clipboard->fileDescriptor)
{ {
for (i = 0; i < clipboard->nFiles; i++) for (i = 0; i < clipboard->nFiles; i++)
{
if (clipboard->fileDescriptor[i])
{ {
free(clipboard->fileDescriptor[i]); free(clipboard->fileDescriptor[i]);
clipboard->fileDescriptor[i] = NULL; clipboard->fileDescriptor[i] = NULL;
} }
} }
}
clipboard->nFiles = 0; clipboard->nFiles = 0;
} }
@ -2069,11 +2052,8 @@ void wf_cliprdr_uninit(wfContext* wfc, CliprdrClientContext* cliprdr)
clear_file_array(clipboard); clear_file_array(clipboard);
clear_format_map(clipboard); clear_format_map(clipboard);
if (clipboard->file_names)
free(clipboard->file_names); free(clipboard->file_names);
if (clipboard->fileDescriptor)
free(clipboard->fileDescriptor); free(clipboard->fileDescriptor);
if (clipboard->format_mappings)
free(clipboard->format_mappings); free(clipboard->format_mappings);
free(clipboard); free(clipboard);

View File

@ -667,7 +667,6 @@ int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
XSetClassHint(xfc->display, appWindow->handle, class_hints); XSetClassHint(xfc->display, appWindow->handle, class_hints);
XFree(class_hints); XFree(class_hints);
if (class)
free(class); free(class);
} }

View File

@ -395,9 +395,7 @@ 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->ServerHostname);
free(settings); free(settings);
return detect_status; return detect_status;

View File

@ -718,7 +718,6 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
status = fclose(fp); status = fclose(fp);
} }
if (buffer)
free(buffer); free(buffer);
return (status == 0) ? TRUE : FALSE; return (status == 0) ? TRUE : FALSE;
@ -777,10 +776,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (domain) if (domain)
freerdp_set_param_string(settings, FreeRDP_Domain, domain); freerdp_set_param_string(settings, FreeRDP_Domain, domain);
if (user)
free(user); free(user);
if (domain)
free(domain); free(domain);
} }

View File

@ -148,17 +148,11 @@ void brush_cache_put(rdpBrushCache* brushCache, UINT32 index, void* entry, UINT3
if (index >= brushCache->maxMonoEntries) if (index >= brushCache->maxMonoEntries)
{ {
WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index); WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index);
if (entry)
free(entry); free(entry);
return; return;
} }
prevEntry = brushCache->monoEntries[index].entry; free(brushCache->monoEntries[index].entry);
if (prevEntry != NULL)
free(prevEntry);
brushCache->monoEntries[index].bpp = bpp; brushCache->monoEntries[index].bpp = bpp;
brushCache->monoEntries[index].entry = entry; brushCache->monoEntries[index].entry = entry;
@ -168,17 +162,11 @@ void brush_cache_put(rdpBrushCache* brushCache, UINT32 index, void* entry, UINT3
if (index >= brushCache->maxEntries) if (index >= brushCache->maxEntries)
{ {
WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index); WLog_ERR(TAG, "invalid brush (%d bpp) index: 0x%04X", bpp, index);
if (entry)
free(entry); free(entry);
return; return;
} }
prevEntry = brushCache->entries[index].entry; free(brushCache->entries[index].entry);
if (prevEntry != NULL)
free(prevEntry);
brushCache->entries[index].bpp = bpp; brushCache->entries[index].bpp = bpp;
brushCache->entries[index].entry = entry; brushCache->entries[index].entry = entry;
@ -233,10 +221,7 @@ void brush_cache_free(rdpBrushCache* brushCache)
if (brushCache->entries) if (brushCache->entries)
{ {
for (i = 0; i < (int) brushCache->maxEntries; i++) for (i = 0; i < (int) brushCache->maxEntries; i++)
{
if (brushCache->entries[i].entry != NULL)
free(brushCache->entries[i].entry); free(brushCache->entries[i].entry);
}
free(brushCache->entries); free(brushCache->entries);
} }
@ -244,10 +229,7 @@ void brush_cache_free(rdpBrushCache* brushCache)
if (brushCache->monoEntries) if (brushCache->monoEntries)
{ {
for (i = 0; i < (int) brushCache->maxMonoEntries; i++) for (i = 0; i < (int) brushCache->maxMonoEntries; i++)
{
if (brushCache->monoEntries[i].entry != NULL)
free(brushCache->monoEntries[i].entry); free(brushCache->monoEntries[i].entry);
}
free(brushCache->monoEntries); free(brushCache->monoEntries);
} }

View File

@ -460,8 +460,6 @@ void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyp
if (prevGlyph) if (prevGlyph)
{ {
Glyph_Free(glyphCache->context, prevGlyph); Glyph_Free(glyphCache->context, prevGlyph);
if (prevGlyph->aj)
free(prevGlyph->aj); free(prevGlyph->aj);
free(prevGlyph); free(prevGlyph);
} }
@ -507,7 +505,6 @@ void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index, UINT32 si
glyphCache->fragCache.entries[index].fragment = fragment; glyphCache->fragCache.entries[index].fragment = fragment;
glyphCache->fragCache.entries[index].size = size; glyphCache->fragCache.entries[index].size = size;
if (prevFragment)
free(prevFragment); free(prevFragment);
} }
@ -568,11 +565,8 @@ void glyph_cache_free(rdpGlyphCache* glyphCache)
if (glyph) if (glyph)
{ {
Glyph_Free(glyphCache->context, glyph); Glyph_Free(glyphCache->context, glyph);
if (glyph->aj)
free(glyph->aj); free(glyph->aj);
free(glyph); free(glyph);
glyphCache->glyphCache[i].entries[j] = NULL; glyphCache->glyphCache[i].entries[j] = NULL;
} }
} }

View File

@ -81,19 +81,13 @@ void* nine_grid_cache_get(rdpNineGridCache* nine_grid, UINT32 index)
void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry) void nine_grid_cache_put(rdpNineGridCache* nine_grid, UINT32 index, void* entry)
{ {
void* prevEntry;
if (index >= nine_grid->maxEntries) if (index >= nine_grid->maxEntries)
{ {
WLog_ERR(TAG, "invalid NineGrid index: 0x%04X", index); WLog_ERR(TAG, "invalid NineGrid index: 0x%04X", index);
return; return;
} }
prevEntry = nine_grid->entries[index].entry; free(nine_grid->entries[index].entry);
if (prevEntry != NULL)
free(prevEntry);
nine_grid->entries[index].entry = entry; nine_grid->entries[index].entry = entry;
} }
@ -130,10 +124,7 @@ void nine_grid_cache_free(rdpNineGridCache* nine_grid)
if (nine_grid->entries != NULL) if (nine_grid->entries != NULL)
{ {
for (i = 0; i < (int) nine_grid->maxEntries; i++) for (i = 0; i < (int) nine_grid->maxEntries; i++)
{
if (nine_grid->entries[i].entry != NULL)
free(nine_grid->entries[i].entry); free(nine_grid->entries[i].entry);
}
free(nine_grid->entries); free(nine_grid->entries);
} }

View File

@ -70,14 +70,10 @@ void palette_cache_put(rdpPaletteCache* paletteCache, UINT32 index, void* entry)
if (index >= paletteCache->maxEntries) if (index >= paletteCache->maxEntries)
{ {
WLog_ERR(TAG, "invalid color table index: 0x%04X", index); WLog_ERR(TAG, "invalid color table index: 0x%04X", index);
if (entry)
free(entry); free(entry);
return; return;
} }
if (paletteCache->entries[index].entry)
free(paletteCache->entries[index].entry); free(paletteCache->entries[index].entry);
paletteCache->entries[index].entry = entry; paletteCache->entries[index].entry = entry;
@ -111,10 +107,7 @@ void palette_cache_free(rdpPaletteCache* paletteCache)
UINT32 i; UINT32 i;
for (i = 0; i< paletteCache->maxEntries; i++) for (i = 0; i< paletteCache->maxEntries; i++)
{
if (paletteCache->entries[i].entry)
free(paletteCache->entries[i].entry); free(paletteCache->entries[i].entry);
}
free(paletteCache->entries); free(paletteCache->entries);
free(paletteCache); free(paletteCache);

View File

@ -1620,9 +1620,7 @@ void freerdp_clrconv_free(HCLRCONV clrconv)
{ {
if (clrconv) if (clrconv)
{ {
if (clrconv->palette)
free(clrconv->palette); free(clrconv->palette);
free(clrconv); free(clrconv);
} }
} }

View File

@ -694,12 +694,8 @@ void freerdp_dsp_context_free(FREERDP_DSP_CONTEXT* context)
{ {
if (context) if (context)
{ {
if (context->resampled_buffer)
free(context->resampled_buffer); free(context->resampled_buffer);
if (context->adpcm_buffer)
free(context->adpcm_buffer); free(context->adpcm_buffer);
free(context); free(context);
} }
} }

View File

@ -2707,9 +2707,6 @@ NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor)
} }
void ncrush_context_free(NCRUSH_CONTEXT* ncrush) void ncrush_context_free(NCRUSH_CONTEXT* ncrush)
{
if (ncrush)
{ {
free(ncrush); free(ncrush);
} }
}

View File

@ -310,7 +310,6 @@ void nsc_context_free(NSC_CONTEXT* context)
} }
} }
if (context->BitmapData)
free(context->BitmapData); free(context->BitmapData);
BufferPool_Free(context->priv->PlanePool); BufferPool_Free(context->priv->PlanePool);

View File

@ -1856,15 +1856,10 @@ PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor)
return progressive; return progressive;
cleanup: cleanup:
if (progressive->rects)
free(progressive->rects); free(progressive->rects);
if (progressive->tiles)
free(progressive->tiles); free(progressive->tiles);
if (progressive->quantVals)
free(progressive->quantVals); free(progressive->quantVals);
if (progressive->quantProgVals)
free(progressive->quantProgVals); free(progressive->quantProgVals);
if (progressive)
free(progressive); free(progressive);
return NULL; return NULL;
} }

View File

@ -408,10 +408,7 @@ ZGFX_CONTEXT* zgfx_context_new(BOOL Compressor)
} }
void zgfx_context_free(ZGFX_CONTEXT* zgfx) void zgfx_context_free(ZGFX_CONTEXT* zgfx)
{
if (zgfx)
{ {
free(zgfx); free(zgfx);
} }
}

View File

@ -181,8 +181,9 @@ int freerdp_assistance_parse_address_list(rdpAssistanceFile* file, char* list)
break; break;
} }
if (tokens)
free(tokens); free(tokens);
return 1; return 1;
} }
@ -523,9 +524,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
{ {
free(PasswordW); free(PasswordW);
free(PassStubW); free(PassStubW);
if (pbIn)
free(pbIn); free(pbIn);
if (pbOut)
free(pbOut); free(pbOut);
return NULL; return NULL;
} }
@ -627,7 +626,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status < 0) if (status < 0)
{ {
if (PasswordW)
free(PasswordW); free(PasswordW);
return -1; return -1;
} }
@ -640,7 +638,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1) if (status != 1)
{ {
if (PasswordW)
free(PasswordW); free(PasswordW);
return -1; return -1;
} }
@ -652,7 +649,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1) if (status != 1)
{ {
if (PasswordW)
free(PasswordW); free(PasswordW);
return -1; return -1;
} }
@ -664,7 +660,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (!pbOut) if (!pbOut)
{ {
if (PasswordW)
free(PasswordW); free(PasswordW);
return -1; return -1;
} }
@ -673,7 +668,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1) if (status != 1)
{ {
if (PasswordW)
free(PasswordW); free(PasswordW);
free(pbOut); free(pbOut);
return -1; return -1;
@ -684,7 +678,6 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1) if (status != 1)
{ {
WLog_ERR(TAG, "EVP_DecryptFinal_ex failure"); WLog_ERR(TAG, "EVP_DecryptFinal_ex failure");
if (PasswordW)
free(PasswordW); free(PasswordW);
free(pbOut); free(pbOut);
return -1; return -1;

View File

@ -345,7 +345,6 @@ void certificate_free_x509_certificate_chain(rdpX509CertChain* x509_cert_chain)
for (i = 0; i < (int)x509_cert_chain->count; i++) for (i = 0; i < (int)x509_cert_chain->count; i++)
{ {
if (x509_cert_chain->array[i].data)
free(x509_cert_chain->array[i].data); free(x509_cert_chain->array[i].data);
} }
@ -591,7 +590,6 @@ BOOL certificate_read_server_x509_certificate_chain(rdpCertificate* certificate,
DEBUG_LICENSE("modulus length:%d", (int) cert_info.ModulusLength); DEBUG_LICENSE("modulus length:%d", (int) cert_info.ModulusLength);
if (cert_info.Modulus)
free(cert_info.Modulus); free(cert_info.Modulus);
if (!ret) if (!ret)
@ -756,7 +754,6 @@ out_free_rsa:
out_free: out_free:
if (fp) if (fp)
fclose(fp); fclose(fp);
if (buffer)
free(buffer); free(buffer);
free(key); free(key);
return NULL; return NULL;
@ -767,9 +764,7 @@ void key_free(rdpRsaKey* key)
if (!key) if (!key)
return; return;
if (key->Modulus)
free(key->Modulus); free(key->Modulus);
free(key->PrivateExponent); free(key->PrivateExponent);
free(key); free(key);
} }
@ -840,7 +835,6 @@ void certificate_free(rdpCertificate* certificate)
certificate_free_x509_certificate_chain(certificate->x509_cert_chain); certificate_free_x509_certificate_chain(certificate->x509_cert_chain);
if (certificate->cert_info.Modulus)
free(certificate->cert_info.Modulus); free(certificate->cert_info.Modulus);
free(certificate); free(certificate);

View File

@ -415,7 +415,6 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp)
/* encrypt client random */ /* encrypt client random */
if (settings->ClientRandom)
free(settings->ClientRandom); free(settings->ClientRandom);
settings->ClientRandomLength = CLIENT_RANDOM_LENGTH; settings->ClientRandomLength = CLIENT_RANDOM_LENGTH;
@ -509,7 +508,6 @@ static BOOL rdp_client_establish_keys(rdpRdp* rdp)
} }
ret = TRUE; ret = TRUE;
end: end:
if (crypt_client_random)
free(crypt_client_random); free(crypt_client_random);
return ret; return ret;
} }
@ -628,10 +626,8 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s)
} }
ret = TRUE; ret = TRUE;
end: end:
if (crypt_client_random)
free(crypt_client_random); free(crypt_client_random);
end2: end2:
if (client_random)
free(client_random); free(client_random);
return ret; return ret;

View File

@ -696,12 +696,9 @@ freerdp* freerdp_new()
* On return, this pointer is not valid anymore. * On return, this pointer is not valid anymore.
*/ */
void freerdp_free(freerdp* instance) void freerdp_free(freerdp* instance)
{
if (instance)
{ {
free(instance); free(instance);
} }
}
FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount) { FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount) {
ULONG written = context->rdp->transport->written; ULONG written = context->rdp->transport->written;

View File

@ -75,9 +75,6 @@ static BOOL strings_equals_nocase(void* obj1, void* obj2)
static void string_free(void* obj1) static void string_free(void* obj1)
{ {
if (!obj1)
return;
free(obj1); free(obj1);
} }
@ -412,13 +409,10 @@ wStream* http_request_write(HttpContext* context, HttpRequest* request)
Stream_Rewind(s, 1); /* don't include null terminator in length */ Stream_Rewind(s, 1); /* don't include null terminator in length */
Stream_Length(s) = Stream_GetPosition(s); Stream_Length(s) = Stream_GetPosition(s);
return s; return s;
out_free:
for (i = 0; i < 9; i++) out_free:
{ for (i = 0; i < count; i++)
if (lines[i])
free(lines[i]); free(lines[i]);
}
free(lines); free(lines);
return NULL; return NULL;
@ -434,21 +428,13 @@ void http_request_free(HttpRequest* request)
if (!request) if (!request)
return; return;
if (request->AuthParam)
free(request->AuthParam); free(request->AuthParam);
if (request->AuthScheme)
free(request->AuthScheme); free(request->AuthScheme);
if (request->Authorization)
free(request->Authorization); free(request->Authorization);
free(request->Content); free(request->Content);
free(request->Method); free(request->Method);
free(request->URI); free(request->URI);
free(request->TransferEncoding); free(request->TransferEncoding);
free(request); free(request);
} }
@ -827,11 +813,9 @@ void http_response_free(HttpResponse* response)
if (!response) if (!response)
return; return;
if (response->lines)
for (i = 0; i < response->count; i++) for (i = 0; i < response->count; i++)
{
if (response->lines && response->lines[i])
free(response->lines[i]); free(response->lines[i]);
}
free(response->lines); free(response->lines);
free(response->ReasonPhrase); free(response->ReasonPhrase);

View File

@ -972,9 +972,7 @@ out:
{ {
if (packet->tsgPacket.packetMsgResponse) if (packet->tsgPacket.packetMsgResponse)
{ {
if (packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage)
free(packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage); free(packet->tsgPacket.packetMsgResponse->messagePacket.reauthMessage);
free(packet->tsgPacket.packetMsgResponse); free(packet->tsgPacket.packetMsgResponse);
} }

View File

@ -542,14 +542,13 @@ LICENSE_PRODUCT_INFO* license_new_product_info()
void license_free_product_info(LICENSE_PRODUCT_INFO* productInfo) void license_free_product_info(LICENSE_PRODUCT_INFO* productInfo)
{ {
if (productInfo->pbCompanyName != NULL) if (productInfo)
{
free(productInfo->pbCompanyName); free(productInfo->pbCompanyName);
if (productInfo->pbProductId != NULL)
free(productInfo->pbProductId); free(productInfo->pbProductId);
free(productInfo); free(productInfo);
} }
}
/** /**
* Read License Binary Blob (LICENSE_BINARY_BLOB).\n * Read License Binary Blob (LICENSE_BINARY_BLOB).\n
@ -656,11 +655,12 @@ LICENSE_BLOB* license_new_binary_blob(UINT16 type)
void license_free_binary_blob(LICENSE_BLOB* blob) void license_free_binary_blob(LICENSE_BLOB* blob)
{ {
if (blob->data != NULL) if (blob)
{
free(blob->data); free(blob->data);
free(blob); free(blob);
} }
}
/** /**
* Read License Scope List (SCOPE_LIST).\n * Read License Scope List (SCOPE_LIST).\n

View File

@ -359,7 +359,6 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance)
#endif #endif
WLog_DBG(TAG, "accept"); WLog_DBG(TAG, "accept");
if (client)
free(client); free(client);
return FALSE; return FALSE;
} }

View File

@ -1336,7 +1336,6 @@ static int update_message_free_update_class(wMessage* msg, int type)
break; break;
case Update_SetBounds: case Update_SetBounds:
if (msg->wParam)
free(msg->wParam); free(msg->wParam);
break; break;
@ -1379,7 +1378,6 @@ static int update_message_free_update_class(wMessage* msg, int type)
break; break;
case Update_SuppressOutput: case Update_SuppressOutput:
if (msg->lParam)
free(msg->lParam); free(msg->lParam);
break; break;
@ -1579,7 +1577,6 @@ static int update_message_free_primary_update_class(wMessage* msg, int type)
case PrimaryUpdate_FastGlyph: case PrimaryUpdate_FastGlyph:
{ {
FAST_GLYPH_ORDER* wParam = (FAST_GLYPH_ORDER*) msg->wParam; FAST_GLYPH_ORDER* wParam = (FAST_GLYPH_ORDER*) msg->wParam;
if (wParam->glyphData.aj)
free(wParam->glyphData.aj); free(wParam->glyphData.aj);
free(wParam); free(wParam);
} }
@ -2870,9 +2867,6 @@ rdpInputProxy* input_message_proxy_new(rdpInput* input)
} }
void input_message_proxy_free(rdpInputProxy* proxy) void input_message_proxy_free(rdpInputProxy* proxy)
{
if (proxy)
{ {
free(proxy); free(proxy);
} }
}

View File

@ -52,8 +52,5 @@ rdpMetrics* metrics_new(rdpContext* context)
void metrics_free(rdpMetrics* metrics) void metrics_free(rdpMetrics* metrics)
{ {
if (!metrics)
return;
free(metrics); free(metrics);
} }

View File

@ -1138,11 +1138,14 @@ rdpNego* nego_new(rdpTransport* transport)
*/ */
void nego_free(rdpNego* nego) void nego_free(rdpNego* nego)
{
if (nego)
{ {
free(nego->RoutingToken); free(nego->RoutingToken);
free(nego->cookie); free(nego->cookie);
free(nego); free(nego);
} }
}
/** /**
* Set target hostname and port. * Set target hostname and port.
@ -1268,7 +1271,7 @@ BOOL nego_set_cookie(rdpNego* nego, char* cookie)
if (nego->cookie) if (nego->cookie)
{ {
free(nego->cookie); free(nego->cookie);
nego->cookie = 0; nego->cookie = NULL;
} }
if (!cookie) if (!cookie)

View File

@ -163,7 +163,6 @@ int nla_client_init(rdpNla* nla)
{ {
if (strlen(settings->PasswordHash) == 32) if (strlen(settings->PasswordHash) == 32)
{ {
if (identity->Password)
free(identity->Password); free(identity->Password);
identity->PasswordLength = ConvertToUnicode(CP_UTF8, 0, identity->PasswordLength = ConvertToUnicode(CP_UTF8, 0,

View File

@ -377,28 +377,13 @@ void redirection_free(rdpRedirection* redirection)
{ {
if (redirection) if (redirection)
{ {
if (redirection->TsvUrl)
free(redirection->TsvUrl); free(redirection->TsvUrl);
if (redirection->Username)
free(redirection->Username); free(redirection->Username);
if (redirection->Domain)
free(redirection->Domain); free(redirection->Domain);
if (redirection->TargetFQDN)
free(redirection->TargetFQDN); free(redirection->TargetFQDN);
if (redirection->TargetNetBiosName)
free(redirection->TargetNetBiosName); free(redirection->TargetNetBiosName);
if (redirection->TargetNetAddress)
free(redirection->TargetNetAddress); free(redirection->TargetNetAddress);
if (redirection->LoadBalanceInfo)
free(redirection->LoadBalanceInfo); free(redirection->LoadBalanceInfo);
if (redirection->Password)
free(redirection->Password); free(redirection->Password);
if (redirection->TargetNetAddresses) if (redirection->TargetNetAddresses)
@ -407,7 +392,6 @@ void redirection_free(rdpRedirection* redirection)
for (i = 0; i < (int) redirection->TargetNetAddressesCount; i++) for (i = 0; i < (int) redirection->TargetNetAddressesCount; i++)
{ {
if (redirection->TargetNetAddresses[i])
free(redirection->TargetNetAddresses[i]); free(redirection->TargetNetAddresses[i]);
} }

View File

@ -1990,7 +1990,6 @@ void update_free(rdpUpdate* update)
free(update->primary->polyline.points); free(update->primary->polyline.points);
free(update->primary->polygon_sc.points); free(update->primary->polygon_sc.points);
if (update->primary->fast_glyph.glyphData.aj)
free(update->primary->fast_glyph.glyphData.aj); free(update->primary->fast_glyph.glyphData.aj);
free(update->primary); free(update->primary);

View File

@ -84,7 +84,6 @@ void crypto_rc4(CryptoRc4 rc4, UINT32 length, const BYTE* in_data, BYTE* out_dat
void crypto_rc4_free(CryptoRc4 rc4) void crypto_rc4_free(CryptoRc4 rc4)
{ {
if (rc4)
free(rc4); free(rc4);
} }
@ -438,7 +437,6 @@ FREERDP_API void crypto_cert_subject_alt_name_free(int count, int *lengths,
{ {
int i; int i;
if (lengths)
free(lengths); free(lengths);
if (alt_name) if (alt_name)

View File

@ -1206,7 +1206,6 @@ int tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname, int por
} }
#ifndef _WIN32 #ifndef _WIN32
if (common_name)
free(common_name); free(common_name);
#endif #endif

View File

@ -87,9 +87,6 @@ rdtkButton* rdtk_button_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
void rdtk_button_free(rdtkButton* button) void rdtk_button_free(rdtkButton* button)
{ {
if (!button)
return;
free(button); free(button);
} }

View File

@ -644,9 +644,7 @@ rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
return font; return font;
cleanup: cleanup:
if (fontImageFile)
free(fontImageFile); free(fontImageFile);
if (fontDescriptorFile)
free(fontDescriptorFile); free(fontDescriptorFile);
if (font) if (font)
{ {
@ -710,9 +708,6 @@ rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, BYTE* imageData, int imageS
void rdtk_font_free(rdtkFont* font) void rdtk_font_free(rdtkFont* font)
{ {
if (!font)
return;
free(font); free(font);
} }

View File

@ -72,9 +72,6 @@ rdtkLabel* rdtk_label_new(rdtkEngine* engine)
void rdtk_label_free(rdtkLabel* label) void rdtk_label_free(rdtkLabel* label)
{ {
if (!label)
return;
free(label); free(label);
} }

View File

@ -87,9 +87,6 @@ rdtkTextField* rdtk_text_field_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
void rdtk_text_field_free(rdtkTextField* textField) void rdtk_text_field_free(rdtkTextField* textField)
{ {
if (!textField)
return;
free(textField); free(textField);
} }

View File

@ -201,11 +201,8 @@ wfServer* wfreerdp_server_new()
} }
void wfreerdp_server_free(wfServer* server) void wfreerdp_server_free(wfServer* server)
{
if (server)
{ {
free(server); free(server);
}
WSACleanup(); WSACleanup();
} }

View File

@ -252,14 +252,11 @@ void shadow_client_refresh_rect(rdpShadowClient* client, BYTE count, RECTANGLE_1
SHADOW_MSG_IN_REFRESH_OUTPUT* wParam; SHADOW_MSG_IN_REFRESH_OUTPUT* wParam;
wMessagePipe* MsgPipe = client->subsystem->MsgPipe; wMessagePipe* MsgPipe = client->subsystem->MsgPipe;
wParam = (SHADOW_MSG_IN_REFRESH_OUTPUT*) calloc(1, sizeof(SHADOW_MSG_IN_REFRESH_OUTPUT)); if (!areas)
return;
if (!wParam || !areas)
{ if (!(wParam = (SHADOW_MSG_IN_REFRESH_OUTPUT*) calloc(1, sizeof(SHADOW_MSG_IN_REFRESH_OUTPUT))))
if (wParam)
free (wParam);
return; return;
}
wParam->numRects = (UINT32) count; wParam->numRects = (UINT32) count;

View File

@ -60,7 +60,6 @@ ASN1module_t ASN1_CreateModule(ASN1uint32_t nVersion, ASN1encodingrule_e eRule,
void ASN1_CloseModule(ASN1module_t pModule) void ASN1_CloseModule(ASN1module_t pModule)
{ {
if (!pModule)
free(pModule); free(pModule);
} }

View File

@ -497,9 +497,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
free(lpLocalDcb); free(lpLocalDcb);
return TRUE; return TRUE;
error_handle: error_handle:
if (lpLocalDcb)
free(lpLocalDcb); free(lpLocalDcb);
return FALSE; return FALSE;
@ -1113,10 +1111,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
error_handle: error_handle:
if (storedDeviceName != NULL)
free(storedDeviceName); free(storedDeviceName);
if (storedTargetPath != NULL)
free(storedTargetPath); free(storedTargetPath);
LeaveCriticalSection(&_CommDevicesLock); LeaveCriticalSection(&_CommDevicesLock);

View File

@ -194,10 +194,7 @@ BOOL CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
certstore = (WINPR_CERTSTORE*) hCertStore; certstore = (WINPR_CERTSTORE*) hCertStore;
if (certstore)
{
free(certstore); free(certstore);
}
return TRUE; return TRUE;
} }

View File

@ -295,7 +295,6 @@ DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock) BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock)
{ {
if (lpszEnvironmentBlock)
free(lpszEnvironmentBlock); free(lpszEnvironmentBlock);
return TRUE; return TRUE;
@ -424,7 +423,6 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
if (!tmp) if (!tmp)
{ {
if (lpszEnvironmentBlock)
free(lpszEnvironmentBlock); free(lpszEnvironmentBlock);
free (mergeStrings); free (mergeStrings);
return NULL; return NULL;
@ -468,7 +466,6 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
if (!tmp) if (!tmp)
{ {
if (lpszEnvironmentBlock)
free(lpszEnvironmentBlock); free(lpszEnvironmentBlock);
free (mergeStrings); free (mergeStrings);
return NULL; return NULL;
@ -584,8 +581,6 @@ BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue)
newEB = MergeEnvironmentStrings((LPCSTR) *envBlock, envstr); newEB = MergeEnvironmentStrings((LPCSTR) *envBlock, envstr);
free(envstr); free(envstr);
if (*envBlock)
free(*envBlock); free(*envBlock);
*envBlock = newEB; *envBlock = newEB;

View File

@ -239,15 +239,9 @@ BOOL FileCloseHandle(HANDLE handle) {
if (pNamedPipe->pfnUnrefNamedPipe) if (pNamedPipe->pfnUnrefNamedPipe)
pNamedPipe->pfnUnrefNamedPipe(pNamedPipe); pNamedPipe->pfnUnrefNamedPipe(pNamedPipe);
if (pNamedPipe->lpFileName) free(pNamedPipe->lpFileName);
free((void*)pNamedPipe->lpFileName); free(pNamedPipe->lpFilePath);
free(pNamedPipe->name);
if (pNamedPipe->lpFilePath)
free((void*)pNamedPipe->lpFilePath);
if (pNamedPipe->name)
free((void*)pNamedPipe->name);
free(pNamedPipe); free(pNamedPipe);
return TRUE; return TRUE;
@ -771,10 +765,7 @@ BOOL FindClose(HANDLE hFindFile)
if (pFileSearch) if (pFileSearch)
{ {
if (pFileSearch->lpPath)
free(pFileSearch->lpPath); free(pFileSearch->lpPath);
if (pFileSearch->lpPattern)
free(pFileSearch->lpPattern); free(pFileSearch->lpPattern);
if (pFileSearch->pDir) if (pFileSearch->pDir)

View File

@ -59,7 +59,7 @@ LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes)
BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
{ {
free(lpMem); free(lpMem);
return 1; return TRUE;
} }
#endif #endif

View File

@ -186,7 +186,6 @@ VOID _RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
{ {
if (UnicodeString) if (UnicodeString)
{ {
if (UnicodeString->Buffer)
free(UnicodeString->Buffer); free(UnicodeString->Buffer);
UnicodeString->Length = 0; UnicodeString->Length = 0;

View File

@ -217,14 +217,9 @@ BOOL NamedPipeCloseHandle(HANDLE handle) {
if (pNamedPipe->pfnUnrefNamedPipe) if (pNamedPipe->pfnUnrefNamedPipe)
pNamedPipe->pfnUnrefNamedPipe(pNamedPipe); pNamedPipe->pfnUnrefNamedPipe(pNamedPipe);
if (pNamedPipe->name)
free(pNamedPipe->name); free(pNamedPipe->name);
free(pNamedPipe->lpFileName);
if (pNamedPipe->lpFileName) free(pNamedPipe->lpFilePath);
free((void*)pNamedPipe->lpFileName);
if (pNamedPipe->lpFilePath)
free((void*)pNamedPipe->lpFilePath);
if (pNamedPipe->serverfd != -1) if (pNamedPipe->serverfd != -1)
close(pNamedPipe->serverfd); close(pNamedPipe->serverfd);
@ -451,12 +446,8 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
if (!pReadPipe || !pWritePipe) if (!pReadPipe || !pWritePipe)
{ {
if (pReadPipe)
free(pReadPipe); free(pReadPipe);
if (pWritePipe)
free(pWritePipe); free(pWritePipe);
return FALSE; return FALSE;
} }

View File

@ -78,9 +78,6 @@ CREDSSP_CONTEXT* credssp_ContextNew()
void credssp_ContextFree(CREDSSP_CONTEXT* context) void credssp_ContextFree(CREDSSP_CONTEXT* context)
{ {
if (!context)
return;
free(context); free(context);
} }

View File

@ -141,7 +141,6 @@ int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
if (status <= 0) if (status <= 0)
{ {
if (TargetName)
free(TargetName); free(TargetName);
return -1; return -1;
} }
@ -603,7 +602,6 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(PCredHandle phCredenti
status = ntlm_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq, status = ntlm_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry); Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
if (pszTargetNameW)
free(pszTargetNameW); free(pszTargetNameW);
return status; return status;

View File

@ -198,7 +198,6 @@ void ntlm_free_unicode_string(PUNICODE_STRING string)
{ {
if (string->Length > 0) if (string->Length > 0)
{ {
if (string->Buffer)
free(string->Buffer); free(string->Buffer);
string->Buffer = NULL; string->Buffer = NULL;

View File

@ -55,9 +55,6 @@ NEGOTIATE_CONTEXT* negotiate_ContextNew()
void negotiate_ContextFree(NEGOTIATE_CONTEXT* context) void negotiate_ContextFree(NEGOTIATE_CONTEXT* context)
{ {
if (!context)
return;
free(context); free(context);
} }

View File

@ -72,9 +72,6 @@ SCHANNEL_CREDENTIALS* schannel_CredentialsNew()
void schannel_CredentialsFree(SCHANNEL_CREDENTIALS* credentials) void schannel_CredentialsFree(SCHANNEL_CREDENTIALS* credentials)
{ {
if (!credentials)
return;
free(credentials); free(credentials);
} }
@ -251,7 +248,6 @@ SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(PCredHandle phCred
status = schannel_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq, status = schannel_InitializeSecurityContextW(phCredential, phContext, pszTargetNameW, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry); Reserved1, TargetDataRep, pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry);
if (pszTargetNameW != NULL)
free(pszTargetNameW); free(pszTargetNameW);
return status; return status;

View File

@ -253,6 +253,9 @@ void* sspi_SecBufferAlloc(PSecBuffer SecBuffer, ULONG size)
void sspi_SecBufferFree(PSecBuffer SecBuffer) void sspi_SecBufferFree(PSecBuffer SecBuffer)
{ {
if (!SecBuffer)
return;
free(SecBuffer->pvBuffer); free(SecBuffer->pvBuffer);
SecBuffer->pvBuffer = NULL; SecBuffer->pvBuffer = NULL;
SecBuffer->cbBuffer = 0; SecBuffer->cbBuffer = 0;
@ -312,9 +315,6 @@ void sspi_SecureHandleSetUpperPointer(SecHandle* handle, void* pointer)
void sspi_SecureHandleFree(SecHandle* handle) void sspi_SecureHandleFree(SecHandle* handle)
{ {
if (!handle)
return;
free(handle); free(handle);
} }
@ -324,7 +324,6 @@ int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, co
identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; identity->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
if (identity->User)
free(identity->User); free(identity->User);
identity->User = (UINT16*) NULL; identity->User = (UINT16*) NULL;
@ -340,7 +339,6 @@ int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, co
identity->UserLength = (ULONG) (status - 1); identity->UserLength = (ULONG) (status - 1);
} }
if (identity->Domain)
free(identity->Domain); free(identity->Domain);
identity->Domain = (UINT16*) NULL; identity->Domain = (UINT16*) NULL;
@ -356,7 +354,6 @@ int sspi_SetAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, co
identity->DomainLength = (ULONG) (status - 1); identity->DomainLength = (ULONG) (status - 1);
} }
if (identity->Password)
free(identity->Password); free(identity->Password);
identity->Password = NULL; identity->Password = NULL;
@ -653,10 +650,7 @@ void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer)
for (index = 0; index < (int) cPackages; index++) for (index = 0; index < (int) cPackages; index++)
{ {
if (pPackageInfo[index].Name)
free(pPackageInfo[index].Name); free(pPackageInfo[index].Name);
if (pPackageInfo[index].Comment)
free(pPackageInfo[index].Comment); free(pPackageInfo[index].Comment);
} }
@ -751,12 +745,11 @@ void FreeContextBuffer_QuerySecurityPackageInfo(void* contextBuffer)
{ {
SecPkgInfo* pPackageInfo = (SecPkgInfo*) contextBuffer; SecPkgInfo* pPackageInfo = (SecPkgInfo*) contextBuffer;
if (pPackageInfo->Name) if (!pPackageInfo)
return;
free(pPackageInfo->Name); free(pPackageInfo->Name);
if (pPackageInfo->Comment)
free(pPackageInfo->Comment); free(pPackageInfo->Comment);
free(pPackageInfo); free(pPackageInfo);
} }

View File

@ -100,15 +100,11 @@ static int LogonUserGetFd(HANDLE handle)
BOOL LogonUserCloseHandle(HANDLE handle) { BOOL LogonUserCloseHandle(HANDLE handle) {
WINPR_ACCESS_TOKEN *token = (WINPR_ACCESS_TOKEN *) handle; WINPR_ACCESS_TOKEN *token = (WINPR_ACCESS_TOKEN *) handle;
if (!LogonUserIsHandled(handle)) if (!handle || !LogonUserIsHandled(handle))
return FALSE; return FALSE;
if (token->Username)
free(token->Username); free(token->Username);
if (token->Domain)
free(token->Domain); free(token->Domain);
free(token); free(token);
return TRUE; return TRUE;

View File

@ -80,7 +80,6 @@ cleanup:
CloseHandle(hTimer); CloseHandle(hTimer);
if (g_Event) if (g_Event)
CloseHandle(g_Event); CloseHandle(g_Event);
if (apcData)
free(apcData); free(apcData);
return status; return status;

View File

@ -300,10 +300,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs)
currentIndex = (p - lpCmdLine); currentIndex = (p - lpCmdLine);
} }
if (lpEscapedCmdLine)
free(lpEscapedCmdLine); free(lpEscapedCmdLine);
if (lpEscapedChars)
free(lpEscapedChars); free(lpEscapedChars);
*pNumArgs = numArgs; *pNumArgs = numArgs;

View File

@ -324,10 +324,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags,
ret = TRUE; ret = TRUE;
finish: finish:
if (filename)
{
free(filename); free(filename);
}
if (pArgs) if (pArgs)
{ {

View File

@ -700,7 +700,6 @@ VOID DumpThreadHandles(void)
} }
} }
if (keys)
free(keys); free(keys);
ListDictionary_Unlock(thread_list); ListDictionary_Unlock(thread_list);

View File

@ -343,17 +343,10 @@ wBitStream* BitStream_New()
wBitStream* bs = NULL; wBitStream* bs = NULL;
bs = (wBitStream*) calloc(1, sizeof(wBitStream)); bs = (wBitStream*) calloc(1, sizeof(wBitStream));
if (bs)
{
}
return bs; return bs;
} }
void BitStream_Free(wBitStream* bs) void BitStream_Free(wBitStream* bs)
{
if (bs)
{ {
free(bs); free(bs);
} }
}

View File

@ -237,9 +237,7 @@ void PubSub_Free(wPubSub* pubSub)
if (pubSub->synchronized) if (pubSub->synchronized)
DeleteCriticalSection(&pubSub->lock); DeleteCriticalSection(&pubSub->lock);
if (pubSub->events)
free(pubSub->events); free(pubSub->events);
free(pubSub); free(pubSub);
} }
} }

View File

@ -75,7 +75,6 @@ wReference* ReferenceTable_GetFreeEntry(wReferenceTable* referenceTable)
if (!referenceTable->size) if (!referenceTable->size)
{ {
if (referenceTable->array)
free(referenceTable->array); free(referenceTable->array);
referenceTable->array = NULL; referenceTable->array = NULL;
return NULL; return NULL;

View File

@ -199,21 +199,18 @@ void winpr_backtrace_free(void *buffer)
#if defined(HAVE_EXECINFO_H) #if defined(HAVE_EXECINFO_H)
t_execinfo *data = (t_execinfo *)buffer; t_execinfo *data = (t_execinfo *)buffer;
if (data->buffer)
free(data->buffer); free(data->buffer);
free(data); free(data);
#elif defined(ANDROID) #elif defined(ANDROID)
t_corkscrew_data *data = (t_corkscrew_data *)buffer; t_corkscrew_data *data = (t_corkscrew_data *)buffer;
if (data->buffer)
free(data->buffer); free(data->buffer);
free(data); free(data);
#elif defined(_WIN32) || defined(_WIN64) #elif defined(_WIN32) || defined(_WIN64)
{ {
t_win_stack *data = (t_win_stack*)buffer; t_win_stack *data = (t_win_stack*)buffer;
if (data->stack)
free(data->stack); free(data->stack);
free(data); free(data);
} }

View File

@ -2609,7 +2609,7 @@ static int lodepng_color_mode_equal(const LodePNGColorMode* a, const LodePNGColo
void lodepng_palette_clear(LodePNGColorMode* info) void lodepng_palette_clear(LodePNGColorMode* info)
{ {
if(info->palette) free(info->palette); free(info->palette);
info->palette = 0; info->palette = 0;
info->palettesize = 0; info->palettesize = 0;
} }
@ -4121,7 +4121,7 @@ static unsigned postProcessScanlines(unsigned char* out, unsigned char* in,
static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength) static unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)
{ {
unsigned pos = 0, i; unsigned pos = 0, i;
if(color->palette) free(color->palette); free(color->palette);
color->palettesize = chunkLength / 3; color->palettesize = chunkLength / 3;
color->palette = (unsigned char*)malloc(4 * color->palettesize); color->palette = (unsigned char*)malloc(4 * color->palettesize);
if(!color->palette && color->palettesize) if(!color->palette && color->palettesize)

View File

@ -102,10 +102,7 @@ void Stream_Free(wStream* s, BOOL bFreeBuffer)
if (s) if (s)
{ {
if (bFreeBuffer) if (bFreeBuffer)
{
if (s->buffer)
free(s->buffer); free(s->buffer);
}
free(s); free(s);
} }

View File

@ -66,9 +66,7 @@ static int compare(const char *src, const char *dst)
cmp = memcmp(a, b, asize); cmp = memcmp(a, b, asize);
cleanup: cleanup:
if (a)
free(a); free(a);
if (b)
free(b); free(b);
return cmp; return cmp;
@ -201,7 +199,7 @@ cleanup:
winpr_image_free(image3, TRUE); winpr_image_free(image3, TRUE);
if (image4) if (image4)
winpr_image_free(image4, TRUE); winpr_image_free(image4, TRUE);
if (buffer)
free(buffer); free(buffer);
return ret; return ret;

View File

@ -218,15 +218,9 @@ void WLog_BinaryAppender_Free(wLog* log, wLogBinaryAppender* appender)
{ {
if (appender) if (appender)
{ {
if (appender->FileName)
free(appender->FileName); free(appender->FileName);
if (appender->FilePath)
free(appender->FilePath); free(appender->FilePath);
if (appender->FullFileName)
free(appender->FullFileName); free(appender->FullFileName);
free(appender); free(appender);
} }
} }

View File

@ -155,9 +155,6 @@ wLogCallbackAppender* WLog_CallbackAppender_New(wLog* log)
} }
void WLog_CallbackAppender_Free(wLog* log, wLogCallbackAppender* appender) void WLog_CallbackAppender_Free(wLog* log, wLogCallbackAppender* appender)
{
if (appender)
{ {
free(appender); free(appender);
} }
}

View File

@ -220,15 +220,9 @@ void WLog_FileAppender_Free(wLog* log, wLogFileAppender* appender)
{ {
if (appender) if (appender)
{ {
if (appender->FileName)
free(appender->FileName); free(appender->FileName);
if (appender->FilePath)
free(appender->FilePath); free(appender->FilePath);
if (appender->FullFileName)
free(appender->FullFileName); free(appender->FullFileName);
free(appender); free(appender);
} }
} }

View File

@ -339,12 +339,9 @@ wLogLayout* WLog_GetLogLayout(wLog* log)
} }
void WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* format) void WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* format)
{
if (layout->FormatString)
{ {
free(layout->FormatString); free(layout->FormatString);
layout->FormatString = NULL; layout->FormatString = NULL;
}
if (format) if (format)
layout->FormatString = _strdup(format); layout->FormatString = _strdup(format);

View File

@ -85,7 +85,6 @@ static void log_recursion(const char* file, const char* fkt, int line)
#endif #endif
if (msg)
free(msg); free(msg);
winpr_backtrace_free(bt); winpr_backtrace_free(bt);

View File

@ -153,7 +153,6 @@ BOOL WINAPI DestroyWindow(HWND hWnd)
free(pWnd->lpClassName); free(pWnd->lpClassName);
if (pWnd->lpWindowName)
free(pWnd->lpWindowName); free(pWnd->lpWindowName);
free(pWnd); free(pWnd);

View File

@ -732,7 +732,6 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
if (status < 0) if (status < 0)
{ {
if (x509_str)
free(x509_str); free(x509_str);
free(filename); free(filename);
free(fullpath); free(fullpath);