From de0f8936f82ef6cdede02299def8a50993fe92c7 Mon Sep 17 00:00:00 2001 From: Víctor Manuel Jáquez Leal Date: Tue, 1 Aug 2017 17:39:04 +0200 Subject: vaapivideobufferpool: don't shift by negative since it's undefined The function g_bit_nth_lsf() may return -1 if the request bit position is not avaible. Thus, this patch check if the return value is not -1 in order to continue. --- gst/vaapi/gstvaapivideobufferpool.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c index dcdc29e9..f4b1a42f 100644 --- a/gst/vaapi/gstvaapivideobufferpool.c +++ b/gst/vaapi/gstvaapivideobufferpool.c @@ -106,11 +106,14 @@ fill_video_alignment (GstVaapiVideoBufferPool * pool, GstVideoAlignment * align) { GstVideoInfo *const vip = &pool->priv->vmeta_vinfo; guint i; + gint nth_bit; gst_video_alignment_reset (align); - for (i = 0; i < GST_VIDEO_INFO_N_PLANES (vip); i++) - align->stride_align[i] = - (1U << g_bit_nth_lsf (GST_VIDEO_INFO_PLANE_STRIDE (vip, i), 0)) - 1; + for (i = 0; i < GST_VIDEO_INFO_N_PLANES (vip); i++) { + nth_bit = g_bit_nth_lsf (GST_VIDEO_INFO_PLANE_STRIDE (vip, i), 0); + if (nth_bit >= 0) + align->stride_align[i] = (1U << nth_bit) - 1; + } } static const gchar ** -- cgit v1.2.3