Free clipboard data properly.
This commit is contained in:
parent
11303e0813
commit
71b1a2e0cc
@ -82,7 +82,7 @@ typedef struct rdp_guac_client_data {
|
|||||||
|
|
||||||
guac_rdp_keysym_state_map keysym_state;
|
guac_rdp_keysym_state_map keysym_state;
|
||||||
|
|
||||||
const char* clipboard;
|
char* clipboard;
|
||||||
|
|
||||||
} rdp_guac_client_data;
|
} rdp_guac_client_data;
|
||||||
|
|
||||||
|
@ -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->rdp_inst = rdp_inst;
|
||||||
guac_client_data->mouse_button_mask = 0;
|
guac_client_data->mouse_button_mask = 0;
|
||||||
guac_client_data->current_surface = GUAC_DEFAULT_LAYER;
|
guac_client_data->current_surface = GUAC_DEFAULT_LAYER;
|
||||||
guac_client_data->clipboard = "";
|
guac_client_data->clipboard = NULL;
|
||||||
|
|
||||||
/* Clear keysym state mapping and keymap */
|
/* Clear keysym state mapping and keymap */
|
||||||
memset(guac_client_data->keysym_state, 0,
|
memset(guac_client_data->keysym_state, 0,
|
||||||
|
@ -420,6 +420,9 @@ int rdp_guac_client_clipboard_handler(guac_client* client, char* data) {
|
|||||||
RDP_EVENT_TYPE_CB_FORMAT_LIST,
|
RDP_EVENT_TYPE_CB_FORMAT_LIST,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
|
/* Free existing data */
|
||||||
|
free(((rdp_guac_client_data*) client->data)->clipboard);
|
||||||
|
|
||||||
/* Store data in client */
|
/* Store data in client */
|
||||||
((rdp_guac_client_data*) client->data)->clipboard = strdup(data);
|
((rdp_guac_client_data*) client->data)->clipboard = strdup(data);
|
||||||
|
|
||||||
|
@ -157,8 +157,14 @@ void guac_rdp_process_cb_data_request(guac_client* client,
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
/* Set data and length */
|
/* Set data and length */
|
||||||
data_response->data = (uint8*) strdup(clipboard);
|
if (clipboard != NULL) {
|
||||||
data_response->size = strlen(clipboard) + 1;
|
data_response->data = (uint8*) strdup(clipboard);
|
||||||
|
data_response->size = strlen(clipboard) + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data_response->data = (uint8*) strdup("");
|
||||||
|
data_response->size = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send response */
|
/* Send response */
|
||||||
freerdp_channels_send_event(channels, (RDP_EVENT*) data_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 */
|
/* Received clipboard data */
|
||||||
if (event->data[event->size - 1] == '\0') {
|
if (event->data[event->size - 1] == '\0') {
|
||||||
|
|
||||||
|
/* Free existing data */
|
||||||
|
free(((rdp_guac_client_data*) client->data)->clipboard);
|
||||||
|
|
||||||
/* Store clipboard data */
|
/* Store clipboard data */
|
||||||
((rdp_guac_client_data*) client->data)->clipboard =
|
((rdp_guac_client_data*) client->data)->clipboard =
|
||||||
strdup((char*) event->data);
|
strdup((char*) event->data);
|
||||||
|
Loading…
Reference in New Issue
Block a user