GUAC-1164: Dispose of layers/buffers when display/cursor are freed.

This commit is contained in:
Michael Jumper 2016-03-15 21:49:26 -07:00
parent fc40e9f14c
commit 2e73e5eef9
2 changed files with 14 additions and 3 deletions

View File

@ -29,6 +29,7 @@
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/layer.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>
#include <guacamole/user.h> #include <guacamole/user.h>
@ -70,13 +71,20 @@ guac_common_cursor* guac_common_cursor_alloc(guac_client* client) {
void guac_common_cursor_free(guac_common_cursor* cursor) { void guac_common_cursor_free(guac_common_cursor* cursor) {
guac_client* client = cursor->client;
guac_layer* layer = cursor->layer;
cairo_surface_t* surface = cursor->surface;
/* Free image buffer and surface */ /* Free image buffer and surface */
free(cursor->image_buffer); free(cursor->image_buffer);
if (cursor->surface != NULL) if (surface != NULL)
cairo_surface_destroy(cursor->surface); cairo_surface_destroy(surface);
/* Destroy layer within remotely-connected client */
guac_protocol_send_dispose(client->socket, layer);
/* Return layer to pool */ /* Return layer to pool */
guac_client_free_layer(cursor->client, cursor->layer); guac_client_free_layer(client, layer);
free(cursor); free(cursor);

View File

@ -84,6 +84,9 @@ static void guac_common_display_free_layers(guac_common_display_layer* layers,
/* Free surface */ /* Free surface */
guac_common_surface_free(current->surface); guac_common_surface_free(current->surface);
/* Destroy layer within remotely-connected client */
guac_protocol_send_dispose(client->socket, layer);
/* Free layer or buffer depending on index */ /* Free layer or buffer depending on index */
if (layer->index < 0) if (layer->index < 0)
guac_client_free_buffer(client, layer); guac_client_free_buffer(client, layer);