diff mbox series

[FFmpeg-devel,12/13] avfilter/vf_elbg: Check call to avpriv_elbg_do()

Message ID AM7PR03MB66609E93E51A5AF4C4284B788FDD9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 6afad4c7e9b9abd785d2b769cbcba3eee4714d48
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>
---
 libavfilter/vf_elbg.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

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

Patch

diff --git a/libavfilter/vf_elbg.c b/libavfilter/vf_elbg.c
index 2c9c861d02..fac3b6f7fe 100644
--- a/libavfilter/vf_elbg.c
+++ b/libavfilter/vf_elbg.c
@@ -142,7 +142,7 @@  static int config_input(AVFilterLink *inlink)
 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
     ELBGFilterContext *const elbg = inlink->dst->priv;
-    int i, j, k;
+    int i, j, k, ret;
     uint8_t *p, *p0;
 
     const uint8_t r_idx  = elbg->rgba_map[R];
@@ -164,9 +164,14 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     }
 
     /* compute the codebook */
-    avpriv_elbg_do(&elbg->ctx, elbg->codeword, NB_COMPONENTS, elbg->codeword_length,
-                   elbg->codebook, elbg->codebook_length, elbg->max_steps_nb,
-                   elbg->codeword_closest_codebook_idxs, &elbg->lfg);
+    ret = avpriv_elbg_do(&elbg->ctx, elbg->codeword, NB_COMPONENTS,
+                         elbg->codeword_length, elbg->codebook,
+                         elbg->codebook_length, elbg->max_steps_nb,
+                         elbg->codeword_closest_codebook_idxs, &elbg->lfg);
+    if (ret < 0) {
+        av_frame_free(&frame);
+        return ret;
+    }
 
     if (elbg->pal8) {
         AVFilterLink *outlink = inlink->dst->outputs[0];