From 3242f5586195d20855563e922deaa1aad45ad3dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 25 Mar 2012 13:35:23 +0100 Subject: [PATCH] test: fix leak in video overlay composition unit test gst_buffer_set_qdata() will leak the structure passed to it when called incorrectly (e.g. on a non-metadata-writable buffer). This is expected, but we must avoid doing that in valgrind. --- gst-libs/gst/video/video-blend.c | 1 + tests/check/libs/video.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/video/video-blend.c b/gst-libs/gst/video/video-blend.c index 78ef7eb..140e2bb 100644 --- a/gst-libs/gst/video/video-blend.c +++ b/gst-libs/gst/video/video-blend.c @@ -1259,6 +1259,7 @@ G_STMT_START { \ ret = v0 + (v1 * (255 - alpha)) / 255; \ } G_STMT_END +/* returns newly-allocated pixels in src->pixels, which caller must g_free() */ void video_blend_scale_linear_RGBA (GstBlendVideoFormatInfo * src, gint dest_height, gint dest_width) diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c index 91a5e4b..4abd0b3 100644 --- a/tests/check/libs/video.c +++ b/tests/check/libs/video.c @@ -25,6 +25,10 @@ #include "config.h" #endif +#ifdef HAVE_VALGRIND +# include +#endif + #include #include @@ -905,8 +909,13 @@ GST_START_TEST (test_overlay_composition) fail_unless (gst_video_buffer_get_overlay_composition (buf) == NULL); gst_buffer_ref (buf); - /* buffer now has refcount of 2, so its metadata is not writable */ - ASSERT_CRITICAL (gst_video_buffer_set_overlay_composition (buf, comp1)); + /* buffer now has refcount of 2, so its metadata is not writable. + * only check this if we are not running in valgrind, as it leaks */ +#ifdef HAVE_VALGRIND + if (!RUNNING_ON_VALGRIND) { + ASSERT_CRITICAL (gst_video_buffer_set_overlay_composition (buf, comp1)); + } +#endif gst_buffer_unref (buf); gst_video_buffer_set_overlay_composition (buf, comp1); fail_unless (gst_video_buffer_get_overlay_composition (buf) == comp1); -- 2.7.4