From: Henric Müller Date: Thu, 9 Jun 2016 13:21:56 +0000 (+0200) Subject: Making sure mono_marshal_free is used instead of g_free in mono_string_builder_to_utf8 X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=18c8694c0dfe135827b627e2dd09b1f0108ee599;p=mono.git Making sure mono_marshal_free is used instead of g_free in mono_string_builder_to_utf8 --- diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index f1d7267630d..923cc99831b 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -938,7 +938,7 @@ mono_string_utf16_to_builder (MonoStringBuilder *sb, gunichar2 *text) * * Returns: a utf8 string with the contents of the StringBuilder. * - * The return value must be released with g_free. + * The return value must be released with mono_marshal_free. * * This is a JIT icall, it sets the pending exception and returns NULL on error. */ @@ -959,14 +959,14 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb) if (gerror) { g_error_free (gerror); - g_free (str_utf16); + mono_marshal_free (str_utf16); mono_set_pending_exception (mono_get_exception_execution_engine ("Failed to convert StringBuilder from utf16 to utf8")); return NULL; } else { guint len = mono_string_builder_capacity (sb) + 1; gchar *res = (gchar *)mono_marshal_alloc (len * sizeof (gchar), &error); if (!mono_error_ok (&error)) { - g_free (str_utf16); + mono_marshal_free (str_utf16); g_free (tmp); mono_error_set_pending_exception (&error); return NULL; @@ -976,7 +976,7 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb) memcpy (res, tmp, str_len * sizeof (gchar)); res[str_len] = '\0'; - g_free (str_utf16); + mono_marshal_free (str_utf16); g_free (tmp); return res; } @@ -990,7 +990,8 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb) * * Returns: a utf16 string with the contents of the StringBuilder. * - * The return value must not be freed. + * The return value must be released with mono_marshal_free. + * * This is a JIT icall, it sets the pending exception and returns NULL on error. */ gunichar2*