Skip to content

Commit

Permalink
ui/vdagent: fix leak on error path
Browse files Browse the repository at this point in the history
"info" was leaked when more than 10 entries.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
elmarco committed Aug 31, 2021
1 parent ad22d05 commit 248c50b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/ui/clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,6 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer,
const void *data,
bool update);

G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuClipboardInfo, qemu_clipboard_info_unref)

#endif /* QEMU_CLIPBOARD_H */
4 changes: 1 addition & 3 deletions ui/vdagent.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg)
uint8_t s = VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD;
uint32_t size = msg->size;
void *data = msg->data;
QemuClipboardInfo *info;
g_autoptr(QemuClipboardInfo) info = NULL;
QemuClipboardType type;

if (have_selection(vd)) {
Expand Down Expand Up @@ -477,7 +477,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg)
size -= sizeof(uint32_t);
}
qemu_clipboard_update(info);
qemu_clipboard_info_unref(info);
break;
case VD_AGENT_CLIPBOARD_REQUEST:
if (size < sizeof(uint32_t)) {
Expand Down Expand Up @@ -523,7 +522,6 @@ static void vdagent_chr_recv_clipboard(VDAgentChardev *vd, VDAgentMessage *msg)
/* set empty clipboard info */
info = qemu_clipboard_info_new(NULL, s);
qemu_clipboard_update(info);
qemu_clipboard_info_unref(info);
}
break;
}
Expand Down

0 comments on commit 248c50b

Please sign in to comment.