libs: encoder: h264fei: remove unnecessary check
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 17 Dec 2019 16:09:37 +0000 (17:09 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 17 Dec 2019 17:31:36 +0000 (18:31 +0100)
Issue detected by Coverity

`info_to_pack.h264_slice_header` is always allocated by
gst_vaapi_feipak_h264_encode(), thus checking it to free it afterwards
in doesn't make much sense.  But it requires to be free on the error
path.

There may be a null pointer dereference, or else the comparison
against null is unnecessary.

In gst_vaapi_encoder_h264_fei_encode: All paths that lead to this null
pointer comparison already dereference the pointer earlier

gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c

index d643a6a..eeec20a 100644 (file)
@@ -2823,8 +2823,7 @@ gst_vaapi_encoder_h264_fei_encode (GstVaapiEncoder * base_encoder,
     }
 
     /* Free the slice array */
-    if (info_to_pak.h264_slice_headers)
-      g_array_free (info_to_pak.h264_slice_headers, TRUE);
+    g_array_free (info_to_pak.h264_slice_headers, TRUE);
 
     gst_vaapi_enc_picture_unref (picture2);
   } else {
@@ -2841,6 +2840,8 @@ error:
         reconstruct);
     if (picture2)
       gst_vaapi_enc_picture_unref (picture2);
+    if (info_to_pak.h264_slice_headers)
+      g_array_free (info_to_pak.h264_slice_headers, TRUE);
     return status;
   }
 }