[FFmpeg-devel] [PATCH] indeo3: check return values of av_malloc()

Paul B Mahol onemda at gmail.com
Sun Jun 30 19:01:15 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/indeo3.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index a6658b7..134210b 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -188,6 +188,9 @@ static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx,
         ctx->planes[p].buffers[0] = av_malloc(!p ? luma_size : chroma_size);
         ctx->planes[p].buffers[1] = av_malloc(!p ? luma_size : chroma_size);
 
+        if (!ctx->planes[p].buffers[0] || !ctx->planes[p].buffers[1])
+            return AVERROR(ENOMEM);
+
         /* fill the INTRA prediction lines with the middle pixel value = 64 */
         memset(ctx->planes[p].buffers[0], 0x40, ctx->planes[p].pitch);
         memset(ctx->planes[p].buffers[1], 0x40, ctx->planes[p].pitch);
@@ -951,8 +954,10 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
             return AVERROR_INVALIDDATA;
         }
         free_frame_buffers(ctx);
-        if ((res = allocate_frame_buffers(ctx, avctx, width, height)) < 0)
-             return res;
+        if ((res = allocate_frame_buffers(ctx, avctx, width, height)) < 0) {
+            free_frame_buffers(ctx);
+            return res;
+        }
         avcodec_set_dimensions(avctx, width, height);
     }
 
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list