x: clean up after xf_pre_connect if connection fails, and free instance where it was allocated

This prevents leak after "Error: protocol security negotiation failure"
This commit is contained in:
Mads Kiilerich 2012-03-16 18:11:53 +01:00
parent 338f7362e3
commit 44b6598252

View File

@ -969,11 +969,17 @@ void xf_window_free(xfInfo* xfi)
XFreeModifiermap(xfi->modifier_map); XFreeModifiermap(xfi->modifier_map);
xfi->modifier_map = 0; xfi->modifier_map = 0;
if (xfi->gc != NULL)
{
XFreeGC(xfi->display, xfi->gc); XFreeGC(xfi->display, xfi->gc);
xfi->gc = 0; xfi->gc = 0;
}
if (xfi->gc_mono != NULL)
{
XFreeGC(xfi->display, xfi->gc_mono); XFreeGC(xfi->display, xfi->gc_mono);
xfi->gc_mono = 0; xfi->gc_mono = 0;
}
if (xfi->window != NULL) if (xfi->window != NULL)
{ {
@ -1070,7 +1076,10 @@ int xfreerdp_run(freerdp* instance)
memset(&timeout, 0, sizeof(struct timeval)); memset(&timeout, 0, sizeof(struct timeval));
if (!freerdp_connect(instance)) if (!freerdp_connect(instance))
{
xf_free(((xfContext*) instance->context)->xfi);
return XF_EXIT_CONN_FAILED; return XF_EXIT_CONN_FAILED;
}
xfi = ((xfContext*) instance->context)->xfi; xfi = ((xfContext*) instance->context)->xfi;
channels = instance->context->channels; channels = instance->context->channels;
@ -1164,10 +1173,6 @@ int xfreerdp_run(freerdp* instance)
gdi_free(instance); gdi_free(instance);
xf_free(xfi); xf_free(xfi);
freerdp_context_free(instance);
freerdp_free(instance);
return ret; return ret;
} }
@ -1257,6 +1262,9 @@ int main(int argc, char* argv[])
pthread_join(thread, NULL); pthread_join(thread, NULL);
pthread_detach(thread); pthread_detach(thread);
freerdp_context_free(instance);
freerdp_free(instance);
freerdp_channels_global_uninit(); freerdp_channels_global_uninit();
return exit_code_from_disconnect_reason(g_disconnect_reason); return exit_code_from_disconnect_reason(g_disconnect_reason);