tests: fix some more leaks
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 27 Jan 2012 11:50:24 +0000 (12:50 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 27 Jan 2012 11:52:01 +0000 (12:52 +0100)
gst/gstdebugutils.c
gst/gstutils.c
libs/gst/base/gstbaseparse.c
tests/check/libs/adapter.c

index eddfdac..8e31bde 100644 (file)
@@ -351,10 +351,10 @@ debug_dump_element_pad_link (GstPad * pad, GstElement * element,
         ) {
       caps = gst_pad_get_current_caps (pad);
       if (!caps)
-        caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+        caps = gst_pad_get_pad_template_caps (pad);
       peer_caps = gst_pad_get_current_caps (peer_pad);
       if (!peer_caps)
-        peer_caps = gst_caps_copy (gst_pad_get_pad_template_caps (peer_pad));
+        peer_caps = gst_pad_get_pad_template_caps (peer_pad);
 
       media = debug_dump_describe_caps (caps, details);
       /* check if peer caps are different */
index 725671b..64aed7f 100644 (file)
@@ -2795,7 +2795,7 @@ query_caps_func (GstPad * pad, QueryCapsData * data)
 gboolean
 gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query)
 {
-  GstCaps *intersected;
+  GstCaps *templ, *intersected;
   QueryCapsData data;
 
   g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
@@ -2811,14 +2811,15 @@ gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query)
 
   gst_pad_forward (pad, (GstPadForwardFunction) query_caps_func, &data);
 
+  templ = gst_pad_get_pad_template_caps (pad);
   if (data.ret) {
-    intersected =
-        gst_caps_intersect (data.ret, gst_pad_get_pad_template_caps (pad));
+    intersected = gst_caps_intersect (data.ret, templ);
     gst_caps_unref (data.ret);
   } else {
-    intersected = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+    intersected = templ;
   }
   gst_query_set_caps_result (query, intersected);
+  gst_caps_unref (templ);
   gst_caps_unref (intersected);
 
   return TRUE;
index 82c8127..767a15d 100644 (file)
@@ -1173,8 +1173,9 @@ gst_base_parse_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
           caps =
               gst_caps_intersect_full (filter, template_caps,
               GST_CAPS_INTERSECT_FIRST);
+          gst_caps_unref (template_caps);
         } else {
-          caps = gst_caps_copy (template_caps);
+          caps = template_caps;
         }
         gst_query_set_caps_result (query, caps);
         gst_caps_unref (caps);
index 73d37a5..bf356b9 100644 (file)
@@ -37,7 +37,7 @@ GST_START_TEST (test_peek1)
   GstBuffer *buffer;
   guint avail;
   GstMapInfo info;
-  const guint8 *data1, *data2;
+  const guint8 *data1, *data2, *idata;
 
   adapter = gst_adapter_new ();
   fail_if (adapter == NULL);
@@ -46,6 +46,8 @@ GST_START_TEST (test_peek1)
   buffer = gst_buffer_new_and_alloc (512);
 
   fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ));
+  idata = info.data;
+  gst_buffer_unmap (buffer, &info);
 
   fail_if (buffer == NULL);
   gst_adapter_push (adapter, buffer);
@@ -69,7 +71,7 @@ GST_START_TEST (test_peek1)
   data1 = gst_adapter_map (adapter, 512);
   fail_if (data1 == NULL);
   /* it should point to the buffer data as well */
-  fail_if (data1 != info.data);
+  fail_if (data1 != idata);
   gst_adapter_unmap (adapter);
 
   data2 = gst_adapter_map (adapter, 512);
@@ -99,7 +101,7 @@ GST_START_TEST (test_peek1)
   fail_if (data2 == NULL);
   /* peek should return the same old pointer + 10 */
   fail_if (data2 != data1 + 10);
-  fail_if (data2 != (guint8 *) info.data + 10);
+  fail_if (data2 != (guint8 *) idata + 10);
   gst_adapter_unmap (adapter);
 
   /* flush some more */
@@ -114,7 +116,7 @@ GST_START_TEST (test_peek1)
   data2 = gst_adapter_map (adapter, 2);
   fail_if (data2 == NULL);
   fail_if (data2 != data1 + 510);
-  fail_if (data2 != (guint8 *) info.data + 510);
+  fail_if (data2 != (guint8 *) idata + 510);
   gst_adapter_unmap (adapter);
 
   /* flush some more */
@@ -228,6 +230,7 @@ GST_START_TEST (test_take3)
   fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ));
   fail_unless (info.data != NULL);
   fail_unless (info.size == 100);
+  gst_buffer_unmap (buffer, &info);
 
   /* set up and push subbuffers */
   buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 25);
@@ -257,6 +260,7 @@ GST_START_TEST (test_take3)
   /* the data should be the same */
   fail_unless (info.data == info2.data);
 
+  gst_buffer_unmap (buffer2, &info2);
   gst_buffer_unref (buffer2);
 
   g_object_unref (adapter);