libs: encoder: h264fei: don't free memory on stack
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 17 Dec 2019 15:49:47 +0000 (16:49 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 17 Dec 2019 17:31:29 +0000 (18:31 +0100)
Issue detected by Coverity

`info_to_pak` variable in gst_vaapi_encoder_h264_fei_encode() is
declared in the stack, but it is free in
gst_vaapi_feienc_h264_encode() as if declared on the heap.

This patch initializes the structure and removes the free.

A non-heap pointer is placed on the free list, likely causing a crash
later.

In gst_vaapi_encoder_h264_fei_encode: Free of an address-of
expression, which can never be heap allocated.

gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c
gst-libs/gst/vaapi/gstvaapifeienc_h264.c

index f5d74a6..e0fbe50 100644 (file)
@@ -2741,7 +2741,7 @@ gst_vaapi_encoder_h264_fei_encode (GstVaapiEncoder * base_encoder,
   GstVaapiEncoderStatus status = GST_VAAPI_ENCODER_STATUS_ERROR_UNKNOWN;
   GstVaapiSurfaceProxy *reconstruct = NULL;
   GstVaapiEncPicture *picture2 = NULL;
-  GstVaapiFeiInfoToPakH264 info_to_pak;
+  GstVaapiFeiInfoToPakH264 info_to_pak = { {0} };
 
   reconstruct = gst_vaapi_encoder_create_surface (base_encoder);
 
index 67fcfbe..ab8642a 100644 (file)
@@ -1403,7 +1403,6 @@ gst_vaapi_feienc_h264_encode (GstVaapiEncoder * base_encoder,
   return GST_VAAPI_ENCODER_STATUS_SUCCESS;
 
 error:
-  g_slice_free (GstVaapiFeiInfoToPakH264, info_to_pak);
   return ret;
 }