diff options
author | Uri Lublin <uril@redhat.com> | 2014-02-27 14:49:59 +0200 |
---|---|---|
committer | Uri Lublin <uril@redhat.com> | 2014-03-09 18:55:40 +0200 |
commit | aed39aeccfec9b9b269fe117d852c4bf7b7af4be (patch) | |
tree | 88656ae4a9633e331e4fa0fe4bd03e6ff8960d4b /vdagent | |
parent | efea0d654bed290fcb183292ae3d62d0ba8a8b35 (diff) |
vdagent: clipboard: GlobalUnlock on handle_request failure
Moved clipboard definition to the beginning of the function, as
mingw-gcc complains about gotos that jump over definitions.
Diffstat (limited to 'vdagent')
-rw-r--r-- | vdagent/vdagent.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 260ee40..3131376 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -1051,9 +1051,10 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques UINT format; HANDLE clip_data; uint8_t* new_data = NULL; - long new_size; + long new_size = 0; size_t len = 0; CxImage image; + VDAgentClipboard* clipboard = NULL; if (_clipboard_owner != owner_guest) { vd_printf("Received clipboard request from client while clipboard is not owned by guest"); @@ -1103,17 +1104,19 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques break; } } + if (!new_size) { - CloseClipboard(); - return false; + vd_printf("clipboard is empty"); + goto handle_clipboard_request_fail; } + msg_size = sizeof(VDAgentMessage) + sizeof(VDAgentClipboard) + new_size; msg = (VDAgentMessage*)new uint8_t[msg_size]; msg->protocol = VD_AGENT_PROTOCOL; msg->type = VD_AGENT_CLIPBOARD; msg->opaque = 0; msg->size = (uint32_t)(sizeof(VDAgentClipboard) + new_size); - VDAgentClipboard* clipboard = (VDAgentClipboard*)msg->data; + clipboard = (VDAgentClipboard*)msg->data; clipboard->type = clipboard_request->type; switch (clipboard_request->type) { @@ -1132,6 +1135,13 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques write_clipboard(msg, msg_size); delete[] (uint8_t *)msg; return true; + +handle_clipboard_request_fail: + if (clipboard_request->type == VD_AGENT_CLIPBOARD_UTF8_TEXT) { + GlobalUnlock(clip_data); + } + CloseClipboard(); + return false; } void VDAgent::handle_clipboard_release() |