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

Rick Kern kernrj at gmail.com
Sun Apr 10 05:50:12 CEST 2016


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

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 196f00b..a3f7e5e 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -714,9 +714,12 @@ 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