From: Michael Jumper Date: Thu, 22 Mar 2012 17:27:57 +0000 (-0700) Subject: Fix memory leaks. X-Git-Url: http://git.alex.org.uk Fix memory leaks. --- diff --git a/src/client.c b/src/client.c index f979147..41b1bbc 100644 --- a/src/client.c +++ b/src/client.c @@ -121,6 +121,7 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { bitmap->Decompress = guac_rdp_bitmap_decompress; bitmap->SetSurface = guac_rdp_bitmap_setsurface; graphics_register_bitmap(context->graphics, bitmap); + xfree(bitmap); /* Set up glyph handling */ glyph = xnew(rdpGlyph); @@ -131,6 +132,7 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { glyph->BeginDraw = guac_rdp_glyph_begindraw; glyph->EndDraw = guac_rdp_glyph_enddraw; graphics_register_glyph(context->graphics, glyph); + xfree(glyph); /* Set up pointer handling */ pointer = xnew(rdpPointer); @@ -139,6 +141,7 @@ boolean rdp_freerdp_pre_connect(freerdp* instance) { pointer->Free = guac_rdp_pointer_free; pointer->Set = guac_rdp_pointer_set; graphics_register_pointer(context->graphics, pointer); + xfree(pointer); /* Set up GDI */ instance->update->Palette = guac_rdp_gdi_palette_update; diff --git a/src/guac_handlers.c b/src/guac_handlers.c index 1e3a08f..932abe2 100644 --- a/src/guac_handlers.c +++ b/src/guac_handlers.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #include @@ -58,11 +60,25 @@ void __guac_rdp_update_keysyms(guac_client* client, const int* keysym_string, in int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed); void __guac_rdp_send_altcode(guac_client* client, int altcode); + int rdp_guac_client_free_handler(guac_client* client) { - /* STUB */ + rdp_guac_client_data* guac_client_data = + (rdp_guac_client_data*) client->data; + + freerdp* rdp_inst = guac_client_data->rdp_inst; + rdpChannels* channels = rdp_inst->context->channels; + + /* Clean up RDP client */ + freerdp_channels_close(channels, rdp_inst); + freerdp_channels_free(channels); + freerdp_disconnect(rdp_inst); + freerdp_clrconv_free(((rdp_freerdp_context*) rdp_inst->context)->clrconv); + cache_free(rdp_inst->context->cache); + freerdp_free(rdp_inst); - /* FIXME: Clean up RDP client + disconnect */ + /* Free client data */ + free(guac_client_data); return 0;