From: Anton Mitrofanov Date: Wed, 9 Jul 2014 13:17:04 +0000 (+0400) Subject: Check malloc during frame dumping X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e93d18b7fe7668f8277b5f117d7e39be24c6070;p=libx264 Check malloc during frame dumping --- diff --git a/encoder/encoder.c b/encoder/encoder.c index bd26a9f4..5305f75b 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -97,11 +97,14 @@ static void x264_frame_dump( x264_t *h ) int cw = h->param.i_width>>1; int ch = h->param.i_height>>CHROMA_V_SHIFT; pixel *planeu = x264_malloc( (cw*ch*2+32)*sizeof(pixel) ); - pixel *planev = planeu + cw*ch + 16; - h->mc.plane_copy_deinterleave( planeu, cw, planev, cw, h->fdec->plane[1], h->fdec->i_stride[1], cw, ch ); - fwrite( planeu, 1, cw*ch*sizeof(pixel), f ); - fwrite( planev, 1, cw*ch*sizeof(pixel), f ); - x264_free( planeu ); + if( planeu ) + { + pixel *planev = planeu + cw*ch + 16; + h->mc.plane_copy_deinterleave( planeu, cw, planev, cw, h->fdec->plane[1], h->fdec->i_stride[1], cw, ch ); + fwrite( planeu, 1, cw*ch*sizeof(pixel), f ); + fwrite( planev, 1, cw*ch*sizeof(pixel), f ); + x264_free( planeu ); + } } fclose( f ); }