diff --git a/protocols/rdp/include/client.h b/protocols/rdp/include/client.h index f3e4dad0..02c6ab6e 100644 --- a/protocols/rdp/include/client.h +++ b/protocols/rdp/include/client.h @@ -82,7 +82,7 @@ typedef struct rdp_guac_client_data { guac_rdp_keysym_state_map keysym_state; - const char* clipboard; + char* clipboard; } rdp_guac_client_data; diff --git a/protocols/rdp/src/client.c b/protocols/rdp/src/client.c index e8c511f4..1dcd3098 100644 --- a/protocols/rdp/src/client.c +++ b/protocols/rdp/src/client.c @@ -368,7 +368,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_client_data->rdp_inst = rdp_inst; guac_client_data->mouse_button_mask = 0; guac_client_data->current_surface = GUAC_DEFAULT_LAYER; - guac_client_data->clipboard = ""; + guac_client_data->clipboard = NULL; /* Clear keysym state mapping and keymap */ memset(guac_client_data->keysym_state, 0, diff --git a/protocols/rdp/src/guac_handlers.c b/protocols/rdp/src/guac_handlers.c index e5977f2c..3b60a288 100644 --- a/protocols/rdp/src/guac_handlers.c +++ b/protocols/rdp/src/guac_handlers.c @@ -420,6 +420,9 @@ int rdp_guac_client_clipboard_handler(guac_client* client, char* data) { RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); + /* Free existing data */ + free(((rdp_guac_client_data*) client->data)->clipboard); + /* Store data in client */ ((rdp_guac_client_data*) client->data)->clipboard = strdup(data); diff --git a/protocols/rdp/src/rdp_cliprdr.c b/protocols/rdp/src/rdp_cliprdr.c index 7770ef9f..ff9860aa 100644 --- a/protocols/rdp/src/rdp_cliprdr.c +++ b/protocols/rdp/src/rdp_cliprdr.c @@ -157,8 +157,14 @@ void guac_rdp_process_cb_data_request(guac_client* client, NULL, NULL); /* Set data and length */ - data_response->data = (uint8*) strdup(clipboard); - data_response->size = strlen(clipboard) + 1; + if (clipboard != NULL) { + data_response->data = (uint8*) strdup(clipboard); + data_response->size = strlen(clipboard) + 1; + } + else { + data_response->data = (uint8*) strdup(""); + data_response->size = 1; + } /* Send response */ freerdp_channels_send_event(channels, (RDP_EVENT*) data_response); @@ -178,6 +184,9 @@ void guac_rdp_process_cb_data_response(guac_client* client, /* Received clipboard data */ if (event->data[event->size - 1] == '\0') { + /* Free existing data */ + free(((rdp_guac_client_data*) client->data)->clipboard); + /* Store clipboard data */ ((rdp_guac_client_data*) client->data)->clipboard = strdup((char*) event->data);