diff options
author | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2009-10-27 16:37:53 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2009-10-27 16:39:56 -0300 |
commit | c3aaf2a3918dbd436f0e6b548f0b919605070608 (patch) | |
tree | a810e1b7546b142bd83da8fcc30edf90f9a757bb /gst/asfmux | |
parent | 7ca8034c51f36251b36ad1aabf8ed3a7b35219b4 (diff) | |
download | gstreamer-plugins-bad-c3aaf2a3918dbd436f0e6b548f0b919605070608.tar.gz |
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.
Diffstat (limited to 'gst/asfmux')
-rw-r--r-- | gst/asfmux/gstasfmux.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gst/asfmux/gstasfmux.c b/gst/asfmux/gstasfmux.c index 7f17169fe..4d4fa2e5a 100644 --- a/gst/asfmux/gstasfmux.c +++ b/gst/asfmux/gstasfmux.c @@ -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; |