matroskademux: fix trailing '*' displayed with some text subtitles

The subtitle buffer we push out should not include a NUL terminator
as part of the data, we just add such a terminator for safety, but
it should not be included in the buffer size.

A NUL terminator is not valid UTF-8, so checks will fail if it's
included in the size, and the NUL will be replaced by the fallback
character specified when converting, i.e. '*'.

https://bugzilla.gnome.org/show_bug.cgi?id=752421
This commit is contained in:
Dimitrios Christidis 2015-07-15 13:44:52 +03:00 committed by Tim-Philipp Müller
parent 0421d40d9c
commit 45892ec8be

View file

@ -2993,6 +2993,7 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
/* Copy old buffer and add a 0 at the end */
gst_buffer_fill (newbuf, 0, map.data, map.size);
gst_buffer_memset (newbuf, map.size, 0, 1);
gst_buffer_set_size (newbuf, map.size);
gst_buffer_unmap (*buf, &map);
gst_buffer_copy_into (newbuf, *buf,
@ -3004,7 +3005,7 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
}
if (!sub_stream->invalid_utf8) {
if (g_utf8_validate ((gchar *) map.data, map.size - 1, NULL)) {
if (g_utf8_validate ((gchar *) map.data, map.size, NULL)) {
goto next;
}
GST_WARNING_OBJECT (element, "subtitle stream %" G_GUINT64_FORMAT