From 2b4274d66767039bab5dee4639a7558b101f46a0 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 27 Mar 2017 11:14:53 +0200 Subject: [PATCH] runtime/cgo: CFRelease result from CFBundleCopyResourceURL The result from CFBundleCopyResourceURL is owned by the caller. This CL adds the necessary CFRelease to release it after use. Fixes #19722 Change-Id: I7afe22ef241d21922a7f5cef6498017e6269a5c3 Reviewed-on: https://go-review.googlesource.com/38639 Run-TryBot: Elias Naur TryBot-Result: Gobot Gobot Reviewed-by: Hyang-Ah Hana Kim --- src/runtime/cgo/gcc_darwin_arm.c | 4 +++- src/runtime/cgo/gcc_darwin_arm64.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/cgo/gcc_darwin_arm.c b/src/runtime/cgo/gcc_darwin_arm.c index 3e1574f66d..bcdddd1016 100644 --- a/src/runtime/cgo/gcc_darwin_arm.c +++ b/src/runtime/cgo/gcc_darwin_arm.c @@ -108,7 +108,9 @@ init_working_dir() } CFStringRef url_str_ref = CFURLGetString(url_ref); char buf[MAXPATHLEN]; - if (!CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8)) { + Boolean res = CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8); + CFRelease(url_ref); + if (!res) { fprintf(stderr, "runtime/cgo: cannot get URL string\n"); return; } diff --git a/src/runtime/cgo/gcc_darwin_arm64.c b/src/runtime/cgo/gcc_darwin_arm64.c index 05b0121d0f..0a69c5d646 100644 --- a/src/runtime/cgo/gcc_darwin_arm64.c +++ b/src/runtime/cgo/gcc_darwin_arm64.c @@ -110,7 +110,9 @@ init_working_dir() } CFStringRef url_str_ref = CFURLGetString(url_ref); char buf[MAXPATHLEN]; - if (!CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8)) { + Boolean res = CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8); + CFRelease(url_ref); + if (!res) { fprintf(stderr, "runtime/cgo: cannot get URL string\n"); return; }