1
0
mirror of https://github.com/golang/go synced 2024-11-17 21:14:44 -07:00

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 <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur 2017-03-27 11:14:53 +02:00
parent f978301144
commit 2b4274d667
2 changed files with 6 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}