Skip to content

Commit

Permalink
Call g_utf8_to_utf16 with a proper argument (mono/mono#5470)
Browse files Browse the repository at this point in the history
* The sizes of `glong` and `gsize` differ on 64-bit Windows.
* In order to avoid uninitialized data in the high four bytes of the `bytes` argument to `mono_unicode_from_external`, call `g_utf8_to_utf16` with a `glong`, then copy the result.

Commit migrated from mono/mono@ee6f896
  • Loading branch information
joshpeterson authored and vargaz committed Aug 30, 2017
1 parent fc95111 commit 298feca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mono/mono/utils/strenc.c
Expand Up @@ -90,8 +90,10 @@ mono_unicode_from_external (const gchar *in, gsize *bytes)
g_strfreev (encodings);

if(g_utf8_validate (in, -1, NULL)) {
gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, (glong *)bytes, NULL);
*bytes *= 2;
glong items_written;
gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, &items_written, NULL);
items_written *= 2;
*bytes = items_written;
return(unires);
}

Expand Down

0 comments on commit 298feca

Please sign in to comment.