]> git.sesse.net Git - x264/commitdiff
Check malloc during frame dumping
authorAnton Mitrofanov <BugMaster@narod.ru>
Wed, 9 Jul 2014 13:17:04 +0000 (17:17 +0400)
committerFiona Glaser <fiona@x264.com>
Sun, 20 Jul 2014 03:53:01 +0000 (20:53 -0700)
encoder/encoder.c

index bd26a9f496be9dbb19f1226629b95d104373ac93..5305f75b7bdbfa03c028e4d47b0ea5915e9a4824 100644 (file)
@@ -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 );
 }