Skip to content
Snippets Groups Projects
Commit 8c0d8024 authored by Akihiko Odaki's avatar Akihiko Odaki Committed by Gerd Hoffmann
Browse files

ui/cocoa: Fix clipboard text release


[-NSPasteboard dataForType:] returns an autoreleased NSString,
and callings its release method will result in double-free when
the global autorelease pool is released. Use NSAutoreleasePool to
release it properly.

Signed-off-by: default avatarAkihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Message-Id: <20220614212131.94696-1-akihiko.odaki@gmail.com>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 839a4826
No related branches found
No related tags found
No related merge requests found
......@@ -1894,16 +1894,18 @@ static void cocoa_clipboard_notify(Notifier *notifier, void *data)
static void cocoa_clipboard_request(QemuClipboardInfo *info,
QemuClipboardType type)
{
NSAutoreleasePool *pool;
NSData *text;
switch (type) {
case QEMU_CLIPBOARD_TYPE_TEXT:
pool = [[NSAutoreleasePool alloc] init];
text = [[NSPasteboard generalPasteboard] dataForType:NSPasteboardTypeString];
if (text) {
qemu_clipboard_set_data(&cbpeer, info, type,
[text length], [text bytes], true);
[text release];
}
[pool release];
break;
default:
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment