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
This commit is contained in:
Vincent Penquerc'h 2014-04-10 12:14:48 +01:00
parent 4a401adf38
commit 3d1fdf8dd8

View file

@ -961,10 +961,14 @@ gst_video_overlay_rectangle_apply_global_alpha (GstVideoOverlayRectangle * rect,
GstVideoFrame frame; GstVideoFrame frame;
gint i, j, w, h, stride; gint i, j, w, h, stride;
gint argb_a, argb_r, argb_g, argb_b; gint argb_a, argb_r, argb_g, argb_b;
gint alpha_offset;
g_assert (!(rect->applied_global_alpha != 1.0 g_assert (!(rect->applied_global_alpha != 1.0
&& rect->initial_alpha == NULL)); && 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) if (global_alpha == rect->applied_global_alpha)
return; return;