msdk: Make sure a variable is initialized when it is used
authorXiang, Haihao <haihao.xiang@intel.com>
Tue, 20 Nov 2018 07:17:44 +0000 (15:17 +0800)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Mon, 26 Nov 2018 16:13:44 +0000 (16:13 +0000)
Previously alloc_info is initialized when both thiz->initialized
and thiz->allocation_caps are true, but only thiz->initialized is
checked when alloc_info is used.

sys/msdk/gstmsdkdec.c

index 8c81380..cb81400 100644 (file)
@@ -893,16 +893,17 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
       goto done;
     }
 
-    if (thiz->initialized && thiz->allocation_caps)
+    if (!thiz->initialized)
+      hard_reset = TRUE;
+    else if (thiz->allocation_caps) {
       gst_video_info_from_caps (&alloc_info, thiz->allocation_caps);
 
-    /* Check whether we need complete reset for dynamic resolution change */
-    if (!thiz->initialized || (thiz->initialized &&
-            (thiz->param.mfx.FrameInfo.Width >
-                GST_VIDEO_INFO_WIDTH (&alloc_info)
-                || thiz->param.mfx.FrameInfo.Height >
-                GST_VIDEO_INFO_HEIGHT (&alloc_info))))
-      hard_reset = TRUE;
+      /* Check whether we need complete reset for dynamic resolution change */
+      if (thiz->param.mfx.FrameInfo.Width > GST_VIDEO_INFO_WIDTH (&alloc_info)
+          || thiz->param.mfx.FrameInfo.Height >
+          GST_VIDEO_INFO_HEIGHT (&alloc_info))
+        hard_reset = TRUE;
+    }
 
     /* if subclass requested for the force reset */
     if (thiz->force_reset_on_res_change)