snow: Check av_frame_alloc() failures
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 29 Aug 2013 21:23:22 +0000 (23:23 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 29 Aug 2013 21:23:22 +0000 (23:23 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/snow.c
libavcodec/snowenc.c

index 4ea82b3..1125b25 100644 (file)
@@ -462,10 +462,14 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
         for(j=0; j<MAX_REF_FRAMES; j++)
             ff_scale_mv_ref[i][j] = 256*(i+1)/(j+1);
         s->last_picture[i] = av_frame_alloc();
         for(j=0; j<MAX_REF_FRAMES; j++)
             ff_scale_mv_ref[i][j] = 256*(i+1)/(j+1);
         s->last_picture[i] = av_frame_alloc();
+        if (!s->last_picture[i])
+            goto fail;
     }
 
     s->mconly_picture = av_frame_alloc();
     s->current_picture = av_frame_alloc();
     }
 
     s->mconly_picture = av_frame_alloc();
     s->current_picture = av_frame_alloc();
+    if (!s->mconly_picture || !s->current_picture)
+        goto fail;
 
     return 0;
 fail:
 
     return 0;
 fail:
index befa4d1..2500575 100644 (file)
@@ -129,6 +129,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
     ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, s->avctx->me_sub_cmp);
 
     s->input_picture = av_frame_alloc();
     ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, s->avctx->me_sub_cmp);
 
     s->input_picture = av_frame_alloc();
+    if (!s->input_picture)
+        return AVERROR(ENOMEM);
     if ((ret = ff_get_buffer(s->avctx, s->input_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;
 
     if ((ret = ff_get_buffer(s->avctx, s->input_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;