test: fix leak in video overlay composition unit test
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 25 Mar 2012 12:35:23 +0000 (13:35 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 25 Mar 2012 12:35:23 +0000 (13:35 +0100)
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
tests/check/libs/video.c

index 78ef7eb..140e2bb 100644 (file)
@@ -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)
index 91a5e4b..4abd0b3 100644 (file)
 #include "config.h"
 #endif
 
+#ifdef HAVE_VALGRIND
+# include <valgrind/valgrind.h>
+#endif
+
 #include <unistd.h>
 
 #include <gst/check/gstcheck.h>
@@ -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);