[FFmpeg-cvslog] avcodec/smc: report error codes instead of silently ignoring them

Paul B Mahol git at videolan.org
Fri Aug 13 20:19:48 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Aug 12 13:50:10 2021 +0200| [b78fccd080d698fd7f8aa37031a1eb0536ac2eae] | committer: Paul B Mahol

avcodec/smc: report error codes instead of silently ignoring them

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b78fccd080d698fd7f8aa37031a1eb0536ac2eae
---

 libavcodec/smc.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 4a832edfcf..704d00859c 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -73,12 +73,12 @@ typedef struct SmcContext {
     total_blocks--; \
     if (total_blocks < !!n_blocks) \
     { \
-        av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
-        return; \
+        av_log(s->avctx, AV_LOG_ERROR, "block counter just went negative (this should not happen)\n"); \
+        return AVERROR_INVALIDDATA; \
     } \
 }
 
-static void smc_decode_stream(SmcContext *s)
+static int smc_decode_stream(SmcContext *s)
 {
     int width = s->avctx->width;
     int height = s->avctx->height;
@@ -118,7 +118,7 @@ static void smc_decode_stream(SmcContext *s)
     bytestream2_skip(&s->gb, 1);
     chunk_size = bytestream2_get_be24(&s->gb);
     if (chunk_size != buf_size)
-        av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
+        av_log(s->avctx, AV_LOG_WARNING, "MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
             chunk_size, buf_size);
 
     chunk_size = buf_size;
@@ -129,13 +129,13 @@ static void smc_decode_stream(SmcContext *s)
         /* sanity checks */
         /* make sure the row pointer hasn't gone wild */
         if (row_ptr >= image_size) {
-            av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
+            av_log(s->avctx, AV_LOG_ERROR, "just went out of bounds (row ptr = %d, height = %d)\n",
                 row_ptr, image_size);
-            return;
+            return AVERROR_INVALIDDATA;
         }
         if (bytestream2_get_bytes_left(&s->gb) < 1) {
             av_log(s->avctx, AV_LOG_ERROR, "input too small\n");
-            return;
+            return AVERROR_INVALIDDATA;
         }
 
         opcode = bytestream2_get_byte(&s->gb);
@@ -156,9 +156,9 @@ static void smc_decode_stream(SmcContext *s)
 
             /* sanity check */
             if ((row_ptr == 0) && (pixel_ptr == 0)) {
-                av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
+                av_log(s->avctx, AV_LOG_ERROR, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
                     opcode & 0xF0);
-                return;
+                return AVERROR_INVALIDDATA;
             }
 
             /* figure out where the previous block started */
@@ -190,9 +190,9 @@ static void smc_decode_stream(SmcContext *s)
 
             /* sanity check */
             if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
-                av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
+                av_log(s->avctx, AV_LOG_ERROR, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
                     opcode & 0xF0);
-                return;
+                return AVERROR_INVALIDDATA;
             }
 
             /* figure out where the previous 2 blocks started */
@@ -409,7 +409,7 @@ static void smc_decode_stream(SmcContext *s)
         }
     }
 
-    return;
+    return 0;
 }
 
 static av_cold int smc_decode_init(AVCodecContext *avctx)
@@ -446,7 +446,9 @@ static int smc_decode_frame(AVCodecContext *avctx,
 
     s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx);
 
-    smc_decode_stream(s);
+    ret = smc_decode_stream(s);
+    if (ret < 0)
+        return ret;
 
     *got_frame      = 1;
     if ((ret = av_frame_ref(data, s->frame)) < 0)



More information about the ffmpeg-cvslog mailing list