[FFmpeg-devel] [PATCH 2/2] vorbisenc: Check the return value of av_frame_clone

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Nov 24 21:27:13 EET 2017


Prevents a segfault when alloc fails.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 libavcodec/vorbisenc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index a4ecd8f754..18a679f2dc 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -1093,9 +1093,13 @@ static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     PutBitContext pb;
 
     if (frame) {
+        AVFrame *clone;
         if ((ret = ff_af_queue_add(&venc->afq, frame)) < 0)
             return ret;
-        ff_bufqueue_add(avctx, &venc->bufqueue, av_frame_clone(frame));
+        clone = av_frame_clone(frame);
+        if (!clone)
+            return AVERROR(ENOMEM);
+        ff_bufqueue_add(avctx, &venc->bufqueue, clone);
     } else
         if (!venc->afq.remaining_samples)
             return 0;
-- 
2.15.0



More information about the ffmpeg-devel mailing list