From 6fb346717be1eb8b7d44b340eb418f1536365888 Mon Sep 17 00:00:00 2001 From: Vineeth TM Date: Thu, 13 Aug 2015 10:31:20 +0900 Subject: [PATCH] spu-pgs: fix buffer and event leak When playing mts files with embedded subtitles, the buffer is mapped, but not unmapped at the end resulting in a memory leak. Also unref event in handle_dvd_event as it takes ownership of the event. https://bugzilla.gnome.org/show_bug.cgi?id=753539 --- gst/dvdspu/gstspu-pgs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gst/dvdspu/gstspu-pgs.c b/gst/dvdspu/gstspu-pgs.c index 785f79c5f9..7e86a29612 100644 --- a/gst/dvdspu/gstspu-pgs.c +++ b/gst/dvdspu/gstspu-pgs.c @@ -683,6 +683,7 @@ gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) guint8 *pos, *end; guint8 type; guint16 packet_len; + gint remaining; gst_buffer_map (buf, &map, GST_MAP_READ); @@ -703,7 +704,6 @@ gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) pos += 2; if (pos + packet_len > end) { - gst_buffer_unmap (buf, &map); PGS_DUMP ("Invalid packet length %u (only have %u bytes)\n", packet_len, end - pos); goto error; @@ -716,7 +716,9 @@ gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf) } while (pos + 3 <= end); PGS_DUMP ("End dumping command buffer with %u bytes remaining\n", end - pos); - return (pos - map.data); + remaining = (gint) (pos - map.data); + gst_buffer_unmap (buf, &map); + return remaining; /* ERRORS */ error: @@ -777,6 +779,7 @@ gstspu_pgs_render (GstDVDSpu * dvdspu, GstVideoFrame * frame) gboolean gstspu_pgs_handle_dvd_event (GstDVDSpu * dvdspu, GstEvent * event) { + gst_event_unref (event); return FALSE; }