tests: fix some more leaks

This commit is contained in:
Wim Taymans 2012-01-27 12:50:24 +01:00
parent eba7fed1d3
commit 21455d35b1
4 changed files with 17 additions and 11 deletions

View file

@ -351,10 +351,10 @@ debug_dump_element_pad_link (GstPad * pad, GstElement * element,
) { ) {
caps = gst_pad_get_current_caps (pad); caps = gst_pad_get_current_caps (pad);
if (!caps) 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); peer_caps = gst_pad_get_current_caps (peer_pad);
if (!peer_caps) 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); media = debug_dump_describe_caps (caps, details);
/* check if peer caps are different */ /* check if peer caps are different */

View file

@ -2795,7 +2795,7 @@ query_caps_func (GstPad * pad, QueryCapsData * data)
gboolean gboolean
gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query) gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query)
{ {
GstCaps *intersected; GstCaps *templ, *intersected;
QueryCapsData data; QueryCapsData data;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE); 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); gst_pad_forward (pad, (GstPadForwardFunction) query_caps_func, &data);
templ = gst_pad_get_pad_template_caps (pad);
if (data.ret) { if (data.ret) {
intersected = intersected = gst_caps_intersect (data.ret, templ);
gst_caps_intersect (data.ret, gst_pad_get_pad_template_caps (pad));
gst_caps_unref (data.ret); gst_caps_unref (data.ret);
} else { } else {
intersected = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); intersected = templ;
} }
gst_query_set_caps_result (query, intersected); gst_query_set_caps_result (query, intersected);
gst_caps_unref (templ);
gst_caps_unref (intersected); gst_caps_unref (intersected);
return TRUE; return TRUE;

View file

@ -1173,8 +1173,9 @@ gst_base_parse_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
caps = caps =
gst_caps_intersect_full (filter, template_caps, gst_caps_intersect_full (filter, template_caps,
GST_CAPS_INTERSECT_FIRST); GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (template_caps);
} else { } else {
caps = gst_caps_copy (template_caps); caps = template_caps;
} }
gst_query_set_caps_result (query, caps); gst_query_set_caps_result (query, caps);
gst_caps_unref (caps); gst_caps_unref (caps);

View file

@ -37,7 +37,7 @@ GST_START_TEST (test_peek1)
GstBuffer *buffer; GstBuffer *buffer;
guint avail; guint avail;
GstMapInfo info; GstMapInfo info;
const guint8 *data1, *data2; const guint8 *data1, *data2, *idata;
adapter = gst_adapter_new (); adapter = gst_adapter_new ();
fail_if (adapter == NULL); fail_if (adapter == NULL);
@ -46,6 +46,8 @@ GST_START_TEST (test_peek1)
buffer = gst_buffer_new_and_alloc (512); buffer = gst_buffer_new_and_alloc (512);
fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ)); fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ));
idata = info.data;
gst_buffer_unmap (buffer, &info);
fail_if (buffer == NULL); fail_if (buffer == NULL);
gst_adapter_push (adapter, buffer); gst_adapter_push (adapter, buffer);
@ -69,7 +71,7 @@ GST_START_TEST (test_peek1)
data1 = gst_adapter_map (adapter, 512); data1 = gst_adapter_map (adapter, 512);
fail_if (data1 == NULL); fail_if (data1 == NULL);
/* it should point to the buffer data as well */ /* it should point to the buffer data as well */
fail_if (data1 != info.data); fail_if (data1 != idata);
gst_adapter_unmap (adapter); gst_adapter_unmap (adapter);
data2 = gst_adapter_map (adapter, 512); data2 = gst_adapter_map (adapter, 512);
@ -99,7 +101,7 @@ GST_START_TEST (test_peek1)
fail_if (data2 == NULL); fail_if (data2 == NULL);
/* peek should return the same old pointer + 10 */ /* peek should return the same old pointer + 10 */
fail_if (data2 != data1 + 10); fail_if (data2 != data1 + 10);
fail_if (data2 != (guint8 *) info.data + 10); fail_if (data2 != (guint8 *) idata + 10);
gst_adapter_unmap (adapter); gst_adapter_unmap (adapter);
/* flush some more */ /* flush some more */
@ -114,7 +116,7 @@ GST_START_TEST (test_peek1)
data2 = gst_adapter_map (adapter, 2); data2 = gst_adapter_map (adapter, 2);
fail_if (data2 == NULL); fail_if (data2 == NULL);
fail_if (data2 != data1 + 510); fail_if (data2 != data1 + 510);
fail_if (data2 != (guint8 *) info.data + 510); fail_if (data2 != (guint8 *) idata + 510);
gst_adapter_unmap (adapter); gst_adapter_unmap (adapter);
/* flush some more */ /* flush some more */
@ -228,6 +230,7 @@ GST_START_TEST (test_take3)
fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ)); fail_unless (gst_buffer_map (buffer, &info, GST_MAP_READ));
fail_unless (info.data != NULL); fail_unless (info.data != NULL);
fail_unless (info.size == 100); fail_unless (info.size == 100);
gst_buffer_unmap (buffer, &info);
/* set up and push subbuffers */ /* set up and push subbuffers */
buffer2 = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 0, 25); 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 */ /* the data should be the same */
fail_unless (info.data == info2.data); fail_unless (info.data == info2.data);
gst_buffer_unmap (buffer2, &info2);
gst_buffer_unref (buffer2); gst_buffer_unref (buffer2);
g_object_unref (adapter); g_object_unref (adapter);