From: Elias Naur Date: Mon, 27 Mar 2017 09:14:53 +0000 (+0200) Subject: runtime/cgo: CFRelease result from CFBundleCopyResourceURL X-Git-Tag: go1.9beta1~960 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2b4274d66767039bab5dee4639a7558b101f46a0;p=gostls13.git 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 --- 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; }