[FFmpeg-devel] [PATCH 2/2] avcodec/mmaldec: Return early upon failure

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Mar 6 01:21:04 EET 2021


This avoids freeing a NULL AVBufferRef*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/mmaldec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 7486f3c526..0ea07ea787 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -495,21 +495,20 @@ static int ffmmal_add_packet(AVCodecContext *avctx, const AVPacket *avpkt,
                 data = buf->data;
             }
         }
-        if (!buf) {
-            ret = AVERROR(ENOMEM);
-            goto done;
-        }
+        if (!buf)
+            return AVERROR(ENOMEM);
+
         if (avpkt)
             ctx->packets_sent++;
     } else {
         data = "";
         if (ctx->eos_sent)
-            goto done;
+            return 0;
         if (!ctx->packets_sent) {
             // Short-cut the flush logic to avoid upsetting MMAL.
             ctx->eos_sent = 1;
             ctx->eos_received = 1;
-            goto done;
+            return 0;
         }
     }
 
-- 
2.27.0



More information about the ffmpeg-devel mailing list