2008-11-27 Mark Probst <mark.probst@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 3 Jan 2009 18:38:36 +0000 (18:38 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 3 Jan 2009 18:38:36 +0000 (18:38 -0000)
Backport of r120164.

* marshal.c (mono_string_builder_to_utf8): Fixed a wrong
invocation to g_utf16_to_utf8().

svn path=/branches/mono-2-2/mono/; revision=122373

mono/metadata/ChangeLog
mono/metadata/marshal.c

index c4747e52d68a14c70f1d09ecfcea6d93b270939a..a82c0757cefe9afccaf32d053cc8193f60813671 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-27  Mark Probst  <mark.probst@gmail.com>
+
+       Backport of r120164.
+       
+       * marshal.c (mono_string_builder_to_utf8): Fixed a wrong
+       invocation to g_utf16_to_utf8().
+
 2008-12-26 Rodrigo Kumpera  <rkumpera@novell.com>
 
        Backport of r122133.
index 64d7dc4de9284c788697392e90adfaa29f220f10..147c9a22eaae20573c7f351efc8ae5fef0a483b1 100644 (file)
@@ -1022,8 +1022,7 @@ gpointer
 mono_string_builder_to_utf8 (MonoStringBuilder *sb)
 {
        GError *error = NULL;
-       glong *res;
-       gchar *tmp;
+       gchar *tmp, *res = NULL;
 
        if (!sb)
                return NULL;
@@ -1037,14 +1036,12 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb)
                sb->cached_str = NULL;
        }
 
-       res = mono_marshal_alloc (mono_stringbuilder_capacity (sb) + 1);
-
-       tmp = g_utf16_to_utf8 (mono_string_chars (sb->str), sb->length, NULL, res, &error);
+       tmp = g_utf16_to_utf8 (mono_string_chars (sb->str), sb->length, NULL, NULL, &error);
        if (error) {
                g_error_free (error);
-               mono_marshal_free (res);
                mono_raise_exception (mono_get_exception_execution_engine ("Failed to convert StringBuilder from utf16 to utf8"));
        } else {
+               res = mono_marshal_alloc (mono_stringbuilder_capacity (sb) + 1);
                memcpy (res, tmp, sb->length + 1);
                g_free (tmp);
        }