From 3d1fdf8dd84cac3c14f829a2e7d75bb12f5c52fa Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 10 Apr 2014 12:14:48 +0100 Subject: [PATCH] video-overlay-composition: guard against NULL pointer dereference on error If gst_video_overlay_rectangle_apply_global_alpha is called with a rectangle with unsuitable alpha, expanding the alpha plane will fail, and thus lead to dereferencing a NULL src pointer. It's not certain this will happen in practice, as the function is static and callers might ensure suitable alpha before calling, but there is no apparent explicit such check. Add prologue asserts for proper alpha to explicitely prevent this. Coverity 1139707 --- gst-libs/gst/video/video-overlay-composition.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gst-libs/gst/video/video-overlay-composition.c b/gst-libs/gst/video/video-overlay-composition.c index 6f22877ada..2f8815c3ad 100644 --- a/gst-libs/gst/video/video-overlay-composition.c +++ b/gst-libs/gst/video/video-overlay-composition.c @@ -961,10 +961,14 @@ gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect, GstVideoFrame frame; gint i, j, w, h, stride; gint argb_a, argb_r, argb_g, argb_b; + gint alpha_offset; g_assert (!(rect->applied_global_alpha != 1.0 && rect->initial_alpha == NULL)); + alpha_offset = GST_VIDEO_INFO_COMP_POFFSET (&rect->info, 3); + g_return_if_fail (alpha_offset == 0 || alpha_offset == 3); + if (global_alpha == rect->applied_global_alpha) return;