[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/8] ui/cocoa: Fix clipboard text release
From: |
Gerd Hoffmann |
Subject: |
[PULL 4/8] ui/cocoa: Fix clipboard text release |
Date: |
Mon, 4 Jul 2022 09:59:42 +0200 |
From: Akihiko Odaki <akihiko.odaki@gmail.com>
[-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>
---
ui/cocoa.m | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 84c84e98fc5e..6a4dccff7f02 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;
--
2.36.1
- [PULL 0/8] Kraxel 20220704 patches, Gerd Hoffmann, 2022/07/04
- [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst, Gerd Hoffmann, 2022/07/04
- [PULL 7/8] docs/system/devices/usb/canokey: remove limitations on qemu-xhci, Gerd Hoffmann, 2022/07/04
- [PULL 2/8] Convert fw_cfg.rst to reStructuredText syntax, Gerd Hoffmann, 2022/07/04
- [PULL 6/8] hw/usb/canokey: fix compatibility of qemu-xhci, Gerd Hoffmann, 2022/07/04
- [PULL 3/8] ui/console: allow display device to be labeled with given id, Gerd Hoffmann, 2022/07/04
- [PULL 4/8] ui/cocoa: Fix clipboard text release,
Gerd Hoffmann <=
- [PULL 5/8] hw/usb/canokey: Fix CCID ZLP, Gerd Hoffmann, 2022/07/04
- [PULL 8/8] hw: canokey: Remove HS support as not compliant to the spec, Gerd Hoffmann, 2022/07/04
- Re: [PULL 0/8] Kraxel 20220704 patches, Richard Henderson, 2022/07/04