diff mbox series

[FFmpeg-devel,11/13] avcodec/msvideo1enc: Check all calls to avpriv_elbg_do()

Message ID AM7PR03MB6660185E481EC707DF2F88008FDD9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 73f47846bd9bf62fed3b9d3f748b858ac7f0a674
Headers show
Series [FFmpeg-devel,01/13] avcodec/elbg: Remove avoidable buffer
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 17, 2021, 2:08 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/msvideo1enc.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Paul B Mahol Sept. 17, 2021, 6:47 a.m. UTC | #1
lgtm
diff mbox series

Patch

diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c
index d43013ba5f..79810ec8c3 100644
--- a/libavcodec/msvideo1enc.c
+++ b/libavcodec/msvideo1enc.c
@@ -118,8 +118,10 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             }
             // try to find optimal value to fill whole 4x4 block
             score = 0;
-            avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->avg,
-                           1, 1, c->output, &c->rnd);
+            ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->avg,
+                                 1, 1, c->output, &c->rnd);
+            if (ret < 0)
+                return ret;
             if(c->avg[0] == 1) // red component = 1 will be written as skip code
                 c->avg[0] = 0;
             for(j = 0; j < 4; j++){
@@ -138,8 +140,10 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             }
             // search for optimal filling of 2-color block
             score = 0;
-            avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->codebook,
-                           2, 1, c->output, &c->rnd);
+            ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->codebook,
+                                 2, 1, c->output, &c->rnd);
+            if (ret < 0)
+                return ret;
             // last output value should be always 1, swap codebooks if needed
             if(!c->output[15]){
                 for(i = 0; i < 3; i++)
@@ -164,9 +168,11 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             // search for optimal filling of 2-color 2x2 subblocks
             score = 0;
             for(i = 0; i < 4; i++){
-                avpriv_elbg_do(&c->elbg, c->block2 + i * 4 * 3, 3, 4,
-                               c->codebook2 + i * 2 * 3, 2, 1,
-                               c->output2 + i*4, &c->rnd);
+                ret = avpriv_elbg_do(&c->elbg, c->block2 + i * 4 * 3, 3, 4,
+                                     c->codebook2 + i * 2 * 3, 2, 1,
+                                     c->output2 + i * 4, &c->rnd);
+                if (ret < 0)
+                    return ret;
             }
             // last value should be always 1, swap codebooks if needed
             if(!c->output2[15]){