[FFmpeg-devel] [PATCH v3 07/12] lavc/videotoolboxenc: Handle out-of-memory and fix memory leak

Rick Kern kernrj at gmail.com
Wed Apr 27 16:53:10 CEST 2016


Signed-off-by: Rick Kern <kernrj at gmail.com>
---
 libavcodec/videotoolboxenc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 72c7ba8..f53015a 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -706,9 +706,14 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
         CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault,
                                               kCFNumberIntType,
                                               &avctx->gop_size);
+        if (!interval) {
+            return AVERROR(ENOMEM);
+        }
+
         status = VTSessionSetProperty(vtctx->session,
                                       kVTCompressionPropertyKey_MaxKeyFrameInterval,
                                       interval);
+        CFRelease(interval);
 
         if (status) {
             av_log(avctx, AV_LOG_ERROR, "Error setting 'max key-frame interval' property: %d\n", status);
-- 
2.7.4



More information about the ffmpeg-devel mailing list