asfmux: fix tag writing bug

g_convert seems to add a single null terminating byte to
the end of the string, even when the output is UTF16, we
force the second 0 byte when copying to the output buffer.
This issue was causing random crashes because it was
assumed that the string resulting from g_convert had
2 extra bytes, but it has only one.
This commit is contained in:
Thiago Santos 2009-10-27 16:37:53 -03:00
parent 7ca8034c51
commit c3aaf2a391

View file

@ -896,8 +896,6 @@ gst_asf_mux_write_string_with_size (GstAsfMux * asfmux,
* tags were with extra weird characters without it.
*/
str_utf16 = g_convert (str, -1, "UTF-16LE", "UTF-8", NULL, &str_size, &error);
str_utf16[str_size + 1] = '\0';
str_utf16[str_size + 2] = '\0';
/* sum up the null terminating char */
str_size += 2;
@ -912,7 +910,10 @@ gst_asf_mux_write_string_with_size (GstAsfMux * asfmux,
g_free (error);
memset (str_buf, 0, str_size);
} else {
memcpy (str_buf, str_utf16, str_size);
/* HACK: g_convert seems to add only a single byte null char to
* the end of the stream, we force the second one */
memcpy (str_buf, str_utf16, str_size - 1);
str_buf[str_size - 1] = 0;
}
g_free (str_utf16);
return str_size;