From 37c0610b4d6b43fc9aea7983d1e82be7fdae6660 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Mon, 16 Oct 2017 13:48:51 +0200 Subject: [PATCH] MacOS: gosxappinfo.c Fix some memory leaks. Fix failure condition. Ensure that the debug call won't crash if create_cstr_from_cfstring returns NULL, fix the leak of that CFArrayRef, and make explicit the failure condition of LSFindApplicationForInfo. https://bugzilla.gnome.org/show_bug.cgi?id=788936 --- gio/gosxappinfo.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gio/gosxappinfo.c b/gio/gosxappinfo.c index 50c1ec30e..463b2da3c 100644 --- a/gio/gosxappinfo.c +++ b/gio/gosxappinfo.c @@ -335,13 +335,18 @@ get_bundle_for_id (CFStringRef bundle_id) } else #else - if (LSFindApplicationForInfo (kLSUnknownCreator, bundle_id, NULL, NULL, &app_url)) + if (LSFindApplicationForInfo (kLSUnknownCreator, bundle_id, NULL, NULL, &app_url) == kLSApplicationNotFoundErr) #endif { #ifdef G_ENABLE_DEBUG /* This can fail often, no reason to alloc strings */ gchar *id_str = create_cstr_from_cfstring (bundle_id); - g_debug ("Application not found for id \"%s\".", id_str); - g_free (id_str); + if (id_str) + { + g_debug ("Application not found for id \"%s\".", id_str); + g_free (id_str); + } + else + g_debug ("Application not found for unconvertable bundle id."); #endif return NULL; } @@ -601,7 +606,7 @@ g_osx_app_info_get_all_for_scheme (const char *cscheme) info = G_APP_INFO (g_osx_app_info_new (bundle)); info_list = g_list_append (info_list, info); } - + CFRelease (bundle_list); return info_list; } @@ -646,7 +651,7 @@ g_app_info_get_all_for_type (const char *content_type) info = G_APP_INFO (g_osx_app_info_new (bundle)); info_list = g_list_append (info_list, info); } - + CFRelease (bundle_list); return info_list; }