diff options
author | Akihiko Odaki <akihiko.odaki@gmail.com> | 2022-06-15 06:21:31 +0900 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2022-07-01 12:35:47 +0200 |
commit | 8c0d80245f3cdbbe6003844751d8fc6b1db7b1e4 (patch) | |
tree | 7e7dbead503452400af82096618c4da442d5f179 /ui | |
parent | 839a482695616c87c7663062f60b7afe48d023a7 (diff) |
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: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220614212131.94696-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cocoa.m | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m index 84c84e98fc..6a4dccff7f 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -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; |