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
This commit is contained in:
Friedrich Beckmann 2017-10-16 13:48:51 +02:00 committed by Philip Withnall
parent 2bd423c54c
commit 37c0610b4d

View File

@ -335,13 +335,18 @@ get_bundle_for_id (CFStringRef bundle_id)
} }
else else
#else #else
if (LSFindApplicationForInfo (kLSUnknownCreator, bundle_id, NULL, NULL, &app_url)) if (LSFindApplicationForInfo (kLSUnknownCreator, bundle_id, NULL, NULL, &app_url) == kLSApplicationNotFoundErr)
#endif #endif
{ {
#ifdef G_ENABLE_DEBUG /* This can fail often, no reason to alloc strings */ #ifdef G_ENABLE_DEBUG /* This can fail often, no reason to alloc strings */
gchar *id_str = create_cstr_from_cfstring (bundle_id); gchar *id_str = create_cstr_from_cfstring (bundle_id);
if (id_str)
{
g_debug ("Application not found for id \"%s\".", id_str); g_debug ("Application not found for id \"%s\".", id_str);
g_free (id_str); g_free (id_str);
}
else
g_debug ("Application not found for unconvertable bundle id.");
#endif #endif
return NULL; 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 = G_APP_INFO (g_osx_app_info_new (bundle));
info_list = g_list_append (info_list, info); info_list = g_list_append (info_list, info);
} }
CFRelease (bundle_list);
return info_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 = G_APP_INFO (g_osx_app_info_new (bundle));
info_list = g_list_append (info_list, info); info_list = g_list_append (info_list, info);
} }
CFRelease (bundle_list);
return info_list; return info_list;
} }