From 84e99060760ee0d9b1e02d2bd98f333428102fdb Mon Sep 17 00:00:00 2001 From: Stéphane Cerveau Date: Tue, 7 Apr 2020 19:59:12 +0200 Subject: omxh26xenc: fix coverity with frame test Coverity was complaining with: Null pointer dereferences (REVERSE_INULL) Null-checking "frame" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. The frame == NULL has been removed as 'frame' is actively used in the code above without any change of dereferencing and setting its value to NULL before the test. CID: 1461287 --- omx/gstomxh264enc.c | 4 +--- omx/gstomxh265enc.c | 5 +---- omx/gstomxvideo.c | 3 ++- omx/gstomxvideoenc.c | 10 +++++++++- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'omx') diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c index 94963e1..51d84a8 100644 --- a/omx/gstomxh264enc.c +++ b/omx/gstomxh264enc.c @@ -879,9 +879,7 @@ gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * enc, GstOMXPort * port, frame->output_buffer = hdrs; flow_ret = gst_video_encoder_finish_subframe (GST_VIDEO_ENCODER (self), frame); - - if (frame) - gst_video_codec_frame_unref (frame); + gst_video_codec_frame_unref (frame); return flow_ret; } else if (self->headers) { diff --git a/omx/gstomxh265enc.c b/omx/gstomxh265enc.c index aaddd5f..3fd8c0d 100644 --- a/omx/gstomxh265enc.c +++ b/omx/gstomxh265enc.c @@ -730,13 +730,10 @@ gst_omx_h265_enc_handle_output_frame (GstOMXVideoEnc * enc, GstOMXPort * port, buf->omx_buf->nFilledLen); gst_buffer_unmap (hdrs, &map); self->headers = g_list_append (self->headers, gst_buffer_ref (hdrs)); - frame->output_buffer = hdrs; flow_ret = gst_video_encoder_finish_subframe (GST_VIDEO_ENCODER (self), frame); - - if (frame) - gst_video_codec_frame_unref (frame); + gst_video_codec_frame_unref (frame); return flow_ret; } else if (self->headers) { diff --git a/omx/gstomxvideo.c b/omx/gstomxvideo.c index 28d7bd1..a761e70 100644 --- a/omx/gstomxvideo.c +++ b/omx/gstomxvideo.c @@ -225,7 +225,8 @@ gst_omx_video_find_nearest_frame (GstElement * element, GstOMXBuffer * buf, GST_TIME_FORMAT ") seems too high (%" GST_TIME_FORMAT ")", GST_TIME_ARGS (timestamp), best->system_frame_number, GST_TIME_ARGS (best->pts), GST_TIME_ARGS (best_diff)); - } + } else + GST_WARNING_OBJECT (element, "No best frame has been found"); g_list_foreach (frames, (GFunc) gst_video_codec_frame_unref, NULL); g_list_free (frames); diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 42a8db4..5da6085 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1707,7 +1707,15 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self) gst_video_encoder_get_frames (GST_VIDEO_ENCODER (self))); g_assert (klass->handle_output_frame); - flow_ret = klass->handle_output_frame (self, self->enc_out_port, buf, frame); + + if (frame) + flow_ret = + klass->handle_output_frame (self, self->enc_out_port, buf, frame); + else { + gst_omx_port_release_buffer (self->enc_out_port, buf); + goto flow_error; + } + GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret)); -- cgit v1.2.3