From ea58aacde27a6c7a912e86ce441bcedf4b603808 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 16 Oct 2023 08:24:09 -0500 Subject: [PATCH] app: [macOS] don't free nil string in ReadClipboard Fixes: https://todo.sr.ht/~eliasnaur/gio/539 Signed-off-by: Elias Naur --- app/os_macos.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/os_macos.go b/app/os_macos.go index 93b7a4e8..9011c231 100644 --- a/app/os_macos.go +++ b/app/os_macos.go @@ -297,7 +297,9 @@ func (w *window) contextView() C.CFTypeRef { func (w *window) ReadClipboard() { cstr := C.readClipboard() - defer C.CFRelease(cstr) + if cstr != 0 { + defer C.CFRelease(cstr) + } content := nsstringToString(cstr) w.w.Event(clipboard.Event{Text: content}) }