Merge pull request #2607 from nfedera/remove_free_null_checks

free can handle NULL perfectly fine
This commit is contained in:
MartinHaimberger 2015-05-11 10:14:30 +02:00
commit 692df124c6
97 changed files with 256 additions and 624 deletions

View File

@ -366,8 +366,7 @@ static void audin_alsa_close(IAudinDevice* device)
alsa->thread = NULL;
}
if (alsa->buffer)
free(alsa->buffer);
free(alsa->buffer);
alsa->buffer = NULL;
alsa->receive = 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)
{
if (audin->subsystem)
free(audin->subsystem);
free(audin->subsystem);
audin->subsystem = _strdup(subsystem);
}
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);
}

View File

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

View File

@ -492,8 +492,6 @@ void audin_server_context_free(audin_server_context* context)
if (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);
}

View File

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

View File

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

View File

@ -132,11 +132,7 @@ void drdynvc_server_context_free(DrdynvcServerContext* context)
{
if (context)
{
if (context->priv)
{
free(context->priv);
}
free(context->priv);
free(context);
}
}

View File

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

View File

@ -263,11 +263,7 @@ void encomsp_server_context_free(EncomspServerContext* context)
{
if (context)
{
if (context->priv)
{
free(context->priv);
}
free(context->priv);
free(context);
}
}

View File

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

View File

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

View File

@ -621,11 +621,7 @@ void rdpdr_server_context_free(RdpdrServerContext* context)
{
if (context)
{
if (context->priv)
{
free(context->priv);
}
free(context->priv);
free(context);
}
}

View File

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

View File

@ -123,10 +123,8 @@ int rdpgfx_decode_h264(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
if (status < 0)
{
if (h264.meta.regionRects)
free(h264.meta.regionRects);
if (h264.meta.quantQualityVals)
free(h264.meta.quantQualityVals);
free(h264.meta.regionRects);
free(h264.meta.quantQualityVals);
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)
{
if (rdpsnd->subsystem)
free(rdpsnd->subsystem);
free(rdpsnd->subsystem);
rdpsnd->subsystem = _strdup(subsystem);
}
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);
}

View File

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

View File

@ -602,17 +602,15 @@ void rdpsnd_server_context_free(RdpsndServerContext* context)
if (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)
freerdp_dsp_context_free(context->priv->dsp_context);
if (context->priv->input_stream)
Stream_Free(context->priv->input_stream, TRUE);
if (context->priv->input_stream)
Stream_Free(context->priv->input_stream, TRUE);
if (context->client_formats)
free(context->client_formats);
free(context->client_formats);
free(context);
}

View File

@ -540,11 +540,7 @@ void remdesk_server_context_free(RemdeskServerContext* context)
{
if (context)
{
if (context->priv)
{
free(context->priv);
}
free(context->priv);
free(context);
}
}

View File

@ -277,8 +277,7 @@ static void serial_process_irp_read(SERIAL_DEVICE* serial, IRP* irp)
Stream_Write(irp->output, buffer, nbRead); /* ReadData */
}
if (buffer)
free(buffer);
free(buffer);
}
static void serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
@ -389,11 +388,8 @@ static void serial_process_irp_device_control(SERIAL_DEVICE* serial, IRP* irp)
/* Stream_Write_UINT8(irp->output, 0); /\* Padding (1 byte) *\/ */
/* } */
if (InputBuffer != NULL)
free(InputBuffer);
if (OutputBuffer != NULL)
free(OutputBuffer);
free(InputBuffer);
free(OutputBuffer);
}
static void serial_process_irp(SERIAL_DEVICE* serial, IRP* irp)
@ -620,8 +616,7 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
irp->IoStatus = STATUS_NO_MEMORY;
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++)
{
rgReaderState = &call->rgReaderStates[index];
if (rgReaderState->szReader)
free((void*) rgReaderState->szReader);
free(rgReaderState->szReader);
}
free(call->rgReaderStates);
@ -508,9 +506,7 @@ static UINT32 smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, SMART
for (index = 0; index < call->cReaders; index++)
{
rgReaderState = &call->rgReaderStates[index];
if (rgReaderState->szReader)
free((void*) rgReaderState->szReader);
free(rgReaderState->szReader);
}
free(call->rgReaderStates);
@ -585,8 +581,7 @@ static UINT32 smartcard_ConnectA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status)
return status;
if (call->szReader)
free(call->szReader);
free(call->szReader);
return ret.ReturnCode;
}
@ -634,8 +629,7 @@ static UINT32 smartcard_ConnectW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status)
return status;
if (call->szReader)
free(call->szReader);
free(call->szReader);
return ret.ReturnCode;
}
@ -923,17 +917,10 @@ static UINT32 smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
if (status != SCARD_S_SUCCESS)
return status;
if (call->pbSendBuffer)
free(call->pbSendBuffer);
if (ret.pbRecvBuffer)
free(ret.pbRecvBuffer);
if (call->pioSendPci)
free(call->pioSendPci);
if (call->pioRecvPci)
free(call->pioRecvPci);
free(call->pbSendBuffer);
free(ret.pbRecvBuffer);
free(call->pioSendPci);
free(call->pioRecvPci);
return ret.ReturnCode;
}
@ -974,11 +961,8 @@ static UINT32 smartcard_Control_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
if (status != SCARD_S_SUCCESS)
return status;
if (call->pvInBuffer)
free(call->pvInBuffer);
if (ret.pvOutBuffer)
free(ret.pvOutBuffer);
free(call->pvInBuffer);
free(ret.pvOutBuffer);
return ret.ReturnCode;
}

View File

@ -499,14 +499,15 @@ static void tsmf_ffmpeg_free(ITSMFDecoder* decoder)
TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*) decoder;
if (mdecoder->frame)
av_free(mdecoder->frame);
if (mdecoder->decoded_data)
free(mdecoder->decoded_data);
free(mdecoder->decoded_data);
if (mdecoder->codec_context)
{
if (mdecoder->prepared)
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);
}
free(decoder);

View File

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

View File

@ -215,9 +215,7 @@ static void tsmf_sample_free(void *arg)
if (!sample)
return;
if (sample->data)
free(sample->data);
free(sample->data);
free(sample);
}
@ -916,8 +914,7 @@ void _tsmf_presentation_free(TSMF_PRESENTATION* presentation)
ArrayList_Clear(presentation->stream_list);
ArrayList_Free(presentation->stream_list);
if (presentation->rects)
free(presentation->rects);
free(presentation->rects);
ZeroMemory(presentation, sizeof(TSMF_PRESENTATION));
free(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)
{
if (urbdrc->subsystem)
free(urbdrc->subsystem);
free(urbdrc->subsystem);
urbdrc->subsystem = _strdup(subsystem);
}

View File

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

View File

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

View File

@ -230,10 +230,9 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type()
break;
}
}
if (tIOHIDDeviceRefs)
free(tIOHIDDeviceRefs);
free(tIOHIDDeviceRefs);
if (deviceCFSetRef)
{
CFRelease(deviceCFSetRef);

View File

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

View File

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

View File

@ -667,8 +667,7 @@ int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
XSetClassHint(xfc->display, appWindow->handle, class_hints);
XFree(class_hints);
if (class)
free(class);
free(class);
}
/* Set the input mode hint for the WM */

View File

@ -395,9 +395,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
detect_status = 1;
}
if (settings->ServerHostname)
free(settings->ServerHostname);
free(settings->ServerHostname);
free(settings);
return detect_status;

View File

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

View File

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

View File

@ -460,9 +460,7 @@ void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyp
if (prevGlyph)
{
Glyph_Free(glyphCache->context, prevGlyph);
if (prevGlyph->aj)
free(prevGlyph->aj);
free(prevGlyph->aj);
free(prevGlyph);
}
@ -507,8 +505,7 @@ void glyph_cache_fragment_put(rdpGlyphCache* glyphCache, UINT32 index, UINT32 si
glyphCache->fragCache.entries[index].fragment = fragment;
glyphCache->fragCache.entries[index].size = size;
if (prevFragment)
free(prevFragment);
free(prevFragment);
}
void glyph_cache_register_callbacks(rdpUpdate* update)
@ -568,11 +565,8 @@ void glyph_cache_free(rdpGlyphCache* glyphCache)
if (glyph)
{
Glyph_Free(glyphCache->context, glyph);
if (glyph->aj)
free(glyph->aj);
free(glyph->aj);
free(glyph);
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* prevEntry;
if (index >= nine_grid->maxEntries)
{
WLog_ERR(TAG, "invalid NineGrid index: 0x%04X", index);
return;
}
prevEntry = nine_grid->entries[index].entry;
if (prevEntry != NULL)
free(prevEntry);
free(nine_grid->entries[index].entry);
nine_grid->entries[index].entry = entry;
}
@ -130,10 +124,7 @@ void nine_grid_cache_free(rdpNineGridCache* nine_grid)
if (nine_grid->entries != NULL)
{
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);
}

View File

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

View File

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

View File

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

View File

@ -2708,8 +2708,5 @@ NCRUSH_CONTEXT* ncrush_context_new(BOOL Compressor)
void ncrush_context_free(NCRUSH_CONTEXT* ncrush)
{
if (ncrush)
{
free(ncrush);
}
free(ncrush);
}

View File

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

View File

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

View File

@ -409,9 +409,6 @@ ZGFX_CONTEXT* zgfx_context_new(BOOL Compressor)
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;
}
if (tokens)
free(tokens);
free(tokens);
return 1;
}
@ -523,10 +524,8 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
{
free(PasswordW);
free(PassStubW);
if (pbIn)
free (pbIn);
if (pbOut)
free (pbOut);
free(pbIn);
free(pbOut);
return NULL;
}
@ -534,8 +533,8 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
{
free(PasswordW);
free(PassStubW);
free (pbIn);
free (pbOut);
free(pbIn);
free(pbOut);
return NULL;
}
@ -627,8 +626,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status < 0)
{
if (PasswordW)
free (PasswordW);
free(PasswordW);
return -1;
}
@ -640,8 +638,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1)
{
if (PasswordW)
free (PasswordW);
free(PasswordW);
return -1;
}
@ -652,8 +649,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1)
{
if (PasswordW)
free (PasswordW);
free(PasswordW);
return -1;
}
@ -664,8 +660,7 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (!pbOut)
{
if (PasswordW)
free (PasswordW);
free(PasswordW);
return -1;
}
@ -673,9 +668,8 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1)
{
if (PasswordW)
free (PasswordW);
free (pbOut);
free(PasswordW);
free(pbOut);
return -1;
}
@ -684,9 +678,8 @@ int freerdp_assistance_decrypt2(rdpAssistanceFile* file, const char* password)
if (status != 1)
{
WLog_ERR(TAG, "EVP_DecryptFinal_ex failure");
if (PasswordW)
free (PasswordW);
free (pbOut);
free(PasswordW);
free(pbOut);
return -1;
}

View File

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

View File

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

View File

@ -697,10 +697,7 @@ freerdp* freerdp_new()
*/
void freerdp_free(freerdp* instance)
{
if (instance)
{
free(instance);
}
free(instance);
}
FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount) {

View File

@ -75,9 +75,6 @@ static BOOL strings_equals_nocase(void* obj1, void* obj2)
static void string_free(void* obj1)
{
if (!obj1)
return;
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_Length(s) = Stream_GetPosition(s);
return s;
out_free:
for (i = 0; i < 9; i++)
{
if (lines[i])
free(lines[i]);
}
out_free:
for (i = 0; i < count; i++)
free(lines[i]);
free(lines);
return NULL;
@ -434,21 +428,13 @@ void http_request_free(HttpRequest* request)
if (!request)
return;
if (request->AuthParam)
free(request->AuthParam);
if (request->AuthScheme)
free(request->AuthScheme);
if (request->Authorization)
free(request->Authorization);
free(request->AuthParam);
free(request->AuthScheme);
free(request->Authorization);
free(request->Content);
free(request->Method);
free(request->URI);
free(request->TransferEncoding);
free(request);
}
@ -827,11 +813,9 @@ void http_response_free(HttpResponse* response)
if (!response)
return;
for (i = 0; i < response->count; i++)
{
if (response->lines && response->lines[i])
if (response->lines)
for (i = 0; i < response->count; i++)
free(response->lines[i]);
}
free(response->lines);
free(response->ReasonPhrase);

View File

@ -972,9 +972,7 @@ out:
{
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);
}

View File

@ -542,13 +542,12 @@ LICENSE_PRODUCT_INFO* license_new_product_info()
void license_free_product_info(LICENSE_PRODUCT_INFO* productInfo)
{
if (productInfo->pbCompanyName != NULL)
if (productInfo)
{
free(productInfo->pbCompanyName);
if (productInfo->pbProductId != NULL)
free(productInfo->pbProductId);
free(productInfo);
free(productInfo);
}
}
/**
@ -656,10 +655,11 @@ LICENSE_BLOB* license_new_binary_blob(UINT16 type)
void license_free_binary_blob(LICENSE_BLOB* blob)
{
if (blob->data != NULL)
if (blob)
{
free(blob->data);
free(blob);
free(blob);
}
}
/**

View File

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

View File

@ -1336,8 +1336,7 @@ static int update_message_free_update_class(wMessage* msg, int type)
break;
case Update_SetBounds:
if (msg->wParam)
free(msg->wParam);
free(msg->wParam);
break;
case Update_Synchronize:
@ -1379,8 +1378,7 @@ static int update_message_free_update_class(wMessage* msg, int type)
break;
case Update_SuppressOutput:
if (msg->lParam)
free(msg->lParam);
free(msg->lParam);
break;
case Update_SurfaceCommand:
@ -1579,8 +1577,7 @@ static int update_message_free_primary_update_class(wMessage* msg, int type)
case PrimaryUpdate_FastGlyph:
{
FAST_GLYPH_ORDER* wParam = (FAST_GLYPH_ORDER*) msg->wParam;
if (wParam->glyphData.aj)
free(wParam->glyphData.aj);
free(wParam->glyphData.aj);
free(wParam);
}
break;
@ -2871,8 +2868,5 @@ rdpInputProxy* input_message_proxy_new(rdpInput* input)
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)
{
if (!metrics)
return;
free(metrics);
}

View File

@ -1139,9 +1139,12 @@ rdpNego* nego_new(rdpTransport* transport)
void nego_free(rdpNego* nego)
{
free(nego->RoutingToken);
free(nego->cookie);
free(nego);
if (nego)
{
free(nego->RoutingToken);
free(nego->cookie);
free(nego);
}
}
/**
@ -1268,7 +1271,7 @@ BOOL nego_set_cookie(rdpNego* nego, char* cookie)
if (nego->cookie)
{
free(nego->cookie);
nego->cookie = 0;
nego->cookie = NULL;
}
if (!cookie)

View File

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

View File

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

View File

@ -1990,8 +1990,7 @@ void update_free(rdpUpdate* update)
free(update->primary->polyline.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->secondary);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -202,10 +202,7 @@ wfServer* wfreerdp_server_new()
void wfreerdp_server_free(wfServer* server)
{
if (server)
{
free(server);
}
free(server);
WSACleanup();
}

View File

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

View File

@ -60,8 +60,7 @@ ASN1module_t ASN1_CreateModule(ASN1uint32_t nVersion, ASN1encodingrule_e eRule,
void ASN1_CloseModule(ASN1module_t pModule)
{
if (!pModule)
free(pModule);
free(pModule);
}
ASN1error_e ASN1_CreateEncoder(ASN1module_t pModule, ASN1encoding_t* ppEncoderInfo,

View File

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

View File

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

View File

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

View File

@ -239,15 +239,9 @@ BOOL FileCloseHandle(HANDLE handle) {
if (pNamedPipe->pfnUnrefNamedPipe)
pNamedPipe->pfnUnrefNamedPipe(pNamedPipe);
if (pNamedPipe->lpFileName)
free((void*)pNamedPipe->lpFileName);
if (pNamedPipe->lpFilePath)
free((void*)pNamedPipe->lpFilePath);
if (pNamedPipe->name)
free((void*)pNamedPipe->name);
free(pNamedPipe->lpFileName);
free(pNamedPipe->lpFilePath);
free(pNamedPipe->name);
free(pNamedPipe);
return TRUE;
@ -771,11 +765,8 @@ BOOL FindClose(HANDLE hFindFile)
if (pFileSearch)
{
if (pFileSearch->lpPath)
free(pFileSearch->lpPath);
if (pFileSearch->lpPattern)
free(pFileSearch->lpPattern);
free(pFileSearch->lpPath);
free(pFileSearch->lpPattern);
if (pFileSearch->pDir)
closedir(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)
{
free(lpMem);
return 1;
return TRUE;
}
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -343,17 +343,10 @@ wBitStream* BitStream_New()
wBitStream* bs = NULL;
bs = (wBitStream*) calloc(1, sizeof(wBitStream));
if (bs)
{
}
return 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)
DeleteCriticalSection(&pubSub->lock);
if (pubSub->events)
free(pubSub->events);
free(pubSub->events);
free(pubSub);
}
}

View File

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

View File

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

View File

@ -2609,7 +2609,7 @@ static int lodepng_color_mode_equal(const LodePNGColorMode* a, const LodePNGColo
void lodepng_palette_clear(LodePNGColorMode* info)
{
if(info->palette) free(info->palette);
free(info->palette);
info->palette = 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)
{
unsigned pos = 0, i;
if(color->palette) free(color->palette);
free(color->palette);
color->palettesize = chunkLength / 3;
color->palette = (unsigned char*)malloc(4 * color->palettesize);
if(!color->palette && color->palettesize)

View File

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

View File

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

View File

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

View File

@ -156,8 +156,5 @@ wLogCallbackAppender* WLog_CallbackAppender_New(wLog* log)
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->FileName)
free(appender->FileName);
if (appender->FilePath)
free(appender->FilePath);
if (appender->FullFileName)
free(appender->FullFileName);
free(appender->FileName);
free(appender->FilePath);
free(appender->FullFileName);
free(appender);
}
}

View File

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

View File

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

View File

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

View File

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