summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorogg.k.ogg.k <ogg.k.ogg.k@googlemail.com>2009-07-20 16:24:23 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-07-20 23:45:47 +0100
commit265b75ca38913c7a9c0281d472f93e7936b6fa91 (patch)
tree9abf75326eeba5cdd4513908b89bb5d740c4abef
parent8ac16a90e4d0cc05a5c1c84c0c04bded901795bb (diff)
downloadgst-plugins-bad-265b75ca38913c7a9c0281d472f93e7936b6fa91.tar.gz
gst-plugins-bad-265b75ca38913c7a9c0281d472f93e7936b6fa91.tar.bz2
gst-plugins-bad-265b75ca38913c7a9c0281d472f93e7936b6fa91.zip
kate: fix some minor memory leaks
Makes 'make check-valgrind' work for the kate unit test (#525743)
-rw-r--r--ext/kate/gstkatetag.c5
-rw-r--r--ext/kate/gstkateutil.c10
-rw-r--r--tests/check/Makefile.am1
-rw-r--r--tests/check/elements/kate.c1
4 files changed, 12 insertions, 5 deletions
diff --git a/ext/kate/gstkatetag.c b/ext/kate/gstkatetag.c
index 7a39c556..f5734c12 100644
--- a/ext/kate/gstkatetag.c
+++ b/ext/kate/gstkatetag.c
@@ -294,7 +294,10 @@ gst_kate_tag_parse_packet (GstKateParse * parse, GstBuffer * buffer)
/* rewrite the language and category */
if (GST_BUFFER_SIZE (buffer) >= 64 && GST_BUFFER_DATA (buffer)[0] == 0x80) {
- buffer = gst_buffer_copy (buffer);
+ GstBuffer *new_buffer = gst_buffer_copy (buffer);
+
+ gst_buffer_unref (buffer);
+ buffer = new_buffer;
/* language is at offset 32, 16 bytes, zero terminated */
if (kt->language) {
diff --git a/ext/kate/gstkateutil.c b/ext/kate/gstkateutil.c
index 78f18dae..b8915d70 100644
--- a/ext/kate/gstkateutil.c
+++ b/ext/kate/gstkateutil.c
@@ -185,7 +185,7 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
gst_pad_set_caps (srcpad, caps);
gst_caps_unref (caps);
if (decoder->k.ki->language && *decoder->k.ki->language) {
- GstTagList *tags = gst_tag_list_new ();
+ GstTagList *old = decoder->tags, *tags = gst_tag_list_new ();
if (tags) {
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_LANGUAGE_CODE,
decoder->k.ki->language, NULL);
@@ -193,6 +193,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
decoder->tags =
gst_tag_list_merge (decoder->tags, tags, GST_TAG_MERGE_REPLACE);
gst_tag_list_free (tags);
+ if (old)
+ gst_tag_list_free (old);
}
}
@@ -212,7 +214,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
GST_INFO_OBJECT (element, "Parsed comments header");
{
gchar *encoder = NULL;
- GstTagList *list = gst_tag_list_from_vorbiscomment_buffer (buf,
+ GstTagList *old = decoder->tags, *list =
+ gst_tag_list_from_vorbiscomment_buffer (buf,
(const guint8 *) "\201kate\0\0\0\0", 9, &encoder);
if (list) {
decoder->tags =
@@ -235,6 +238,9 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
GST_TAG_ENCODER_VERSION, decoder->k.ki->bitstream_version_major,
NULL);
+ if (old)
+ gst_tag_list_free (old);
+
if (decoder->initialized) {
gst_element_found_tags_for_pad (element, srcpad, decoder->tags);
decoder->tags = NULL;
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 41581363..1aa99d1a 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -71,7 +71,6 @@ endif
VALGRIND_TO_FIX = \
- elements/kate \
elements/mpeg2enc \
elements/mplex
diff --git a/tests/check/elements/kate.c b/tests/check/elements/kate.c
index 80ea6882..551d72a1 100644
--- a/tests/check/elements/kate.c
+++ b/tests/check/elements/kate.c
@@ -413,7 +413,6 @@ GST_START_TEST (test_kate_encode_empty)
1 * GST_SECOND;
GST_BUFFER_DURATION (inbuffer) = 5 * GST_SECOND;
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
- gst_buffer_ref (inbuffer);
caps = gst_caps_from_string ("text/plain");
fail_unless (caps != NULL);