From 45892ec8becdc6b5d1d72a1b90b42f90b699cf7e Mon Sep 17 00:00:00 2001 From: Dimitrios Christidis Date: Wed, 15 Jul 2015 13:44:52 +0300 Subject: [PATCH] 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 --- gst/matroska/matroska-demux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 3ec8c704b8..77f9bdf77c 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -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