diff mbox series

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

Message ID 20210305232104.496745-2-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/mmaldec: Stop needlessly wrapping extradata in AVPacket
Related show

Checks

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

Commit Message

Andreas Rheinhardt March 5, 2021, 11:21 p.m. UTC
This avoids freeing a NULL AVBufferRef*.

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

Patch

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;
         }
     }