From c90afffef6a064aa4c017416a5a48d0ecf37b84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 20 Sep 2022 15:41:08 +0200 Subject: gosxcontenttype: Do not mix declarations with code Fixes: #2759 --- gio/gosxcontenttype.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gio/gosxcontenttype.m b/gio/gosxcontenttype.m index 6119bbcae..a8d14f881 100644 --- a/gio/gosxcontenttype.m +++ b/gio/gosxcontenttype.m @@ -58,13 +58,18 @@ create_cfstring_from_cstr (const gchar *cstr) static gchar * create_cstr_from_cfstring (CFStringRef str) { + CFIndex length; + CFIndex maxlen; + gchar *buffer; + Boolean success; + g_return_val_if_fail (str != NULL, NULL); - CFIndex length = CFStringGetLength (str); - CFIndex maxlen = CFStringGetMaximumSizeForEncoding (length, kCFStringEncodingUTF8); - gchar *buffer = g_malloc (maxlen + 1); - Boolean success = CFStringGetCString (str, (char *) buffer, maxlen, - kCFStringEncodingUTF8); + length = CFStringGetLength (str); + maxlen = CFStringGetMaximumSizeForEncoding (length, kCFStringEncodingUTF8); + buffer = g_malloc (maxlen + 1); + success = CFStringGetCString (str, (char *) buffer, maxlen, + kCFStringEncodingUTF8); CFRelease (str); if (success) return buffer; -- cgit v1.2.1