Commit 45892ec8 authored by Dimitrios Christidis's avatar Dimitrios Christidis Committed by Tim-Philipp Müller

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
parent 0421d40d
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment