diff mbox series

[FFmpeg-devel,2/3] lavfi/dnn/dnn_io_proc.c: fix Improper use of negative value (NEGATIVE_RETURNS)

Message ID 20210511074112.18552-2-yejun.guo@intel.com
State Accepted
Commit 3fb1d2e71c1c92ce282b373cd0319bfec56be2db
Headers show
Series [FFmpeg-devel,1/3] lavfi/dnn/dnn_io_proc.c: Fix Out-of-bounds access (ARRAY_VS_SINGLETON) | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate fail Make fate failed
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

Guo, Yejun May 11, 2021, 7:41 a.m. UTC
fix coverity CID 1473511 and 1473566
---
 libavfilter/dnn/dnn_io_proc.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index d5d2654162..02c8e13ed7 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -28,6 +28,9 @@  DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l
 {
     struct SwsContext *sws_ctx;
     int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
+    if (bytewidth < 0) {
+        return DNN_ERROR;
+    }
     if (output->dt != DNN_FLOAT) {
         avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT");
         return DNN_ERROR;
@@ -98,6 +101,9 @@  static DNNReturnType proc_from_frame_to_dnn_frameprocessing(AVFrame *frame, DNND
 {
     struct SwsContext *sws_ctx;
     int bytewidth = av_image_get_linesize(frame->format, frame->width, 0);
+    if (bytewidth < 0) {
+        return DNN_ERROR;
+    }
     if (input->dt != DNN_FLOAT) {
         avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT");
         return DNN_ERROR;