From e05c492bd912200b057d41f12c4d1c103ae6638c Mon Sep 17 00:00:00 2001 From: Andre Miranda Date: Fri, 24 Jan 2025 22:11:37 +0100 Subject: [PATCH] gosxappinfo: Fix leak Slightly reworked by Philip Withnall (any mistakes his). --- gio/gosxappinfo.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gio/gosxappinfo.m b/gio/gosxappinfo.m index c6ca699a2..01ae85167 100644 --- a/gio/gosxappinfo.m +++ b/gio/gosxappinfo.m @@ -228,11 +228,16 @@ create_url_from_cstr_or_file (gpointer data, gboolean is_file) { const char *cstr; + char *cstr_owned = NULL; gchar *puny_cstr; CFStringRef str; CFURLRef url; - cstr = is_file ? g_file_get_uri ((GFile *) data) : (char *) data; + if (is_file) + cstr = cstr_owned = g_file_get_uri ((GFile *) data); + else + cstr = (char *) data; + puny_cstr = url_escape_hostname (cstr); str = CFStringCreateWithCString (NULL, puny_cstr ? puny_cstr : cstr, kCFStringEncodingUTF8); url = CFURLCreateWithString (NULL, str, NULL); @@ -240,6 +245,7 @@ create_url_from_cstr_or_file (gpointer data, if (!url) g_debug ("Creating CFURL from %s %s failed!", cstr, is_file ? "file" : "uri"); + g_free (cstr_owned); g_free (puny_cstr); CFRelease(str); return url;