[FFmpeg-devel] [PATCH] avcodec/libutvideoenc: Check avpicture_get_size() return code

Michael Niedermayer michaelni at gmx.at
Thu Dec 11 14:09:07 CET 2014


Fixes CID1257656

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/libutvideoenc.cpp |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libutvideoenc.cpp b/libavcodec/libutvideoenc.cpp
index 3298e64..a96b126 100644
--- a/libavcodec/libutvideoenc.cpp
+++ b/libavcodec/libutvideoenc.cpp
@@ -39,6 +39,7 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
     UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
     UtVideoExtra *info;
     uint32_t flags, in_format;
+    int ret;
 
     switch (avctx->pix_fmt) {
     case AV_PIX_FMT_YUV420P:
@@ -94,8 +95,11 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
      * We use this buffer to hold the data that Ut Video returns,
      * since we cannot decode planes separately with it.
      */
-    utv->buf_size = avpicture_get_size(avctx->pix_fmt,
-                                       avctx->width, avctx->height);
+    ret = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+    if (ret < 0)
+        return ret;
+    utv->buf_size = ret;
+
     utv->buffer = (uint8_t *)av_malloc(utv->buf_size);
 
     if (utv->buffer == NULL) {
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list