summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gio/gosxcontenttype.m15
1 files 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;