const GValue *val;
GstStructure *s;
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
+ const gchar *end;
GstBuffer *priv;
GstMapInfo map;
gchar *ptr;
- gsize left;
+ gsize left, bad_offset;
gboolean ret;
s = gst_caps_get_structure (caps, 0);
gst_buffer_ref (priv);
- gst_buffer_map (priv, &map, GST_MAP_READ);
+ if (!gst_buffer_map (priv, &map, GST_MAP_READ))
+ return FALSE;
+
+ GST_MEMDUMP_OBJECT (parse, "init section", map.data, map.size);
ptr = (gchar *) map.data;
left = map.size;
if (!strstr (ptr, "[Script Info]"))
goto invalid_init;
- if (!g_utf8_validate (ptr, left, NULL))
- goto invalid_utf8;
+ if (!g_utf8_validate (ptr, left, &end)) {
+ bad_offset = (gsize) (end - ptr);
+ GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8. Problem at "
+ "byte offset %" G_GSIZE_FORMAT, bad_offset);
+ /* continue with valid UTF-8 data */
+ left = bad_offset;
+ }
/* FIXME: parse initial section */
parse->ini = g_strndup (ptr, left);
gst_buffer_unref (priv);
return FALSE;
}
-invalid_utf8:
- {
- GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
- gst_buffer_unmap (priv, &map);
- gst_buffer_unref (priv);
- return FALSE;
- }
}
static gboolean