matroskademux: fix memory leak in check_subtitle_buffer

https://bugzilla.gnome.org/show_bug.cgi?id=704921
This commit is contained in:
Matej Knopp 2013-07-26 16:02:01 +02:00 committed by Sebastian Dröge
parent 3c44cd7c83
commit 7335b81c47

View file

@ -2977,6 +2977,7 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
GstBuffer *newbuf;
gchar *utf8;
GstMapInfo map;
gboolean needs_unmap = TRUE;
sub_stream = (GstMatroskaTrackSubtitleContext *) stream;
@ -3027,10 +3028,10 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
utf8 = g_strdup ("invalid subtitle");
newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
gst_buffer_unmap (*buf, &map);
gst_buffer_copy_into (newbuf, *buf,
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_META,
0, -1);
gst_buffer_unmap (*buf, &map);
gst_buffer_unref (*buf);
*buf = newbuf;
@ -3047,16 +3048,20 @@ next:
utf8 = g_markup_escape_text ((gchar *) map.data, map.size);
newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
gst_buffer_unmap (*buf, &map);
gst_buffer_copy_into (newbuf, *buf,
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS |
GST_BUFFER_COPY_META, 0, -1);
gst_buffer_unmap (*buf, &map);
gst_buffer_unref (*buf);
*buf = newbuf;
needs_unmap = FALSE;
}
}
if (needs_unmap)
gst_buffer_unmap (*buf, &map);
return GST_FLOW_OK;
}