diff --git a/ChangeLog b/ChangeLog index 0121bcb068..8d3efc4324 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-06-21 Tim-Philipp Müller + + * ext/pango/gsttextoverlay.c: (gst_text_overlay_make_utf8), + (gst_text_overlay_video_chain): + g_markup_escape_text() REALLY doesn't like non-UTF8 input + and doesn't validate its input either (and neither did + textoverlay it seems). Let's do that then and fix #345206. + 2006-06-19 Wim Taymans * gst/tcp/gstmultifdsink.c: (gst_sync_method_get_type), diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index 2caa7674d1..d604b86394 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -1324,12 +1324,24 @@ gst_text_overlay_video_chain (GstPad * pad, GstBuffer * buffer) /* Push the video frame */ ret = gst_pad_push (overlay->srcpad, buffer); } else { - const gchar *in_text; + gchar *in_text; gsize in_size; - in_text = (const gchar *) GST_BUFFER_DATA (overlay->text_buffer); + in_text = (gchar *) GST_BUFFER_DATA (overlay->text_buffer); in_size = GST_BUFFER_SIZE (overlay->text_buffer); + /* g_markup_escape_text() absolutely requires valid UTF8 input, it + * might crash otherwise. We don't fall back on GST_SUBTITLE_ENCODING + * here on purpose, this is something that needs fixing upstream */ + if (!g_utf8_validate (in_text, in_size, NULL)) { + const gchar *end = NULL; + + GST_WARNING_OBJECT (overlay, "received invalid UTF-8"); + in_text = g_strndup (in_text, in_size); + while (!g_utf8_validate (in_text, in_size, &end) && end) + *((gchar *) end) = '*'; + } + /* Get the string */ if (overlay->have_pango_markup) { text = g_strndup (in_text, in_size); @@ -1351,6 +1363,9 @@ gst_text_overlay_video_chain (GstPad * pad, GstBuffer * buffer) gst_text_overlay_render_text (overlay, " ", 1); } + if (in_text != (gchar *) GST_BUFFER_DATA (overlay->text_buffer)) + g_free (in_text); + GST_OBJECT_UNLOCK (overlay); ret = gst_text_overlay_push_frame (overlay, buffer); }