From 413fc302351b9fbcea4167d460bb13f60a5ea14a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 4 Apr 2015 00:42:52 +0100 Subject: [PATCH] videorate: fix a couple of memory leaks tests: videorate: fix leak in unit test --- gst/videorate/gstvideorate.c | 12 ++++++++---- tests/check/elements/videorate.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index f432ecedb..08e86782a 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -371,8 +371,6 @@ gst_video_rate_transform_caps (GstBaseTransform * trans, s = gst_caps_get_structure (caps, i); s1 = gst_structure_copy (s); - s2 = gst_structure_copy (s); - s3 = NULL; if (videorate->updating_caps) { GST_INFO_OBJECT (trans, @@ -384,7 +382,12 @@ gst_video_rate_transform_caps (GstBaseTransform * trans, ret = gst_caps_merge_structure (ret, s1); continue; - } else if (videorate->drop_only) { + } + + s2 = gst_structure_copy (s); + s3 = NULL; + + if (videorate->drop_only) { gint min_num = 0, min_denom = 1; gint max_num = G_MAXINT, max_denom = 1; @@ -1004,7 +1007,6 @@ gst_video_rate_check_variable_rate (GstVideoRate * videorate, GstStructure *st; gint fps_d, fps_n; GstCaps *srcpadcaps, *tmpcaps; - GstPad *pad = NULL; srcpadcaps = @@ -1012,6 +1014,7 @@ gst_video_rate_check_variable_rate (GstVideoRate * videorate, gst_video_guess_framerate (GST_BUFFER_PTS (buffer) - GST_BUFFER_PTS (videorate->prevbuf), &fps_n, &fps_d); + tmpcaps = gst_caps_copy (srcpadcaps); st = gst_caps_get_structure (tmpcaps, 0); gst_structure_set (st, "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL); @@ -1036,6 +1039,7 @@ gst_video_rate_check_variable_rate (GstVideoRate * videorate, gst_base_transform_update_src_caps (GST_BASE_TRANSFORM (videorate), tmpcaps); done: + gst_caps_unref (tmpcaps); if (pad) gst_object_unref (pad); } diff --git a/tests/check/elements/videorate.c b/tests/check/elements/videorate.c index ec57b7038..7bb886106 100644 --- a/tests/check/elements/videorate.c +++ b/tests/check/elements/videorate.c @@ -1095,7 +1095,7 @@ videorate_send_buffers (GstElement * videorate, GST_START_TEST (test_fixed_framerate) { GstElement *videorate; - GstCaps *caps = gst_caps_from_string ("video/x-raw,framerate=0/1"); + GstCaps *caps; /* 1) if upstream caps contain a non-0/1 framerate, we should use that and pass * it on downstream (if possible; otherwise fixate_to_nearest) -- 2.34.1