]> granicus.if.org Git - libx264/commitdiff
Fix malloc of zero size
authorAnton Mitrofanov <BugMaster@narod.ru>
Thu, 10 Feb 2011 13:05:53 +0000 (05:05 -0800)
committerFiona Glaser <fiona@x264.com>
Fri, 18 Feb 2011 09:51:38 +0000 (01:51 -0800)
Caused x264 to fail with some settings on systems that return a NULL pointer for malloc(0), like Solaris.

common/macroblock.c

index aec5c6a1c0b35a9ca6f8c84a5698d61bdbc04a02..8f0b82cdc8deea632ebba74d47c89bc623b1d99f 100644 (file)
@@ -340,7 +340,10 @@ int x264_macroblock_thread_allocate( x264_t *h, int b_lookahead )
     }
     int buf_mbtree = h->param.rc.b_mb_tree * ((h->mb.i_mb_width+3)&~3) * sizeof(int);
     scratch_size = X264_MAX( scratch_size, buf_mbtree );
-    CHECKED_MALLOC( h->scratch_buffer, scratch_size );
+    if( scratch_size )
+        CHECKED_MALLOC( h->scratch_buffer, scratch_size );
+    else
+        h->scratch_buffer = NULL;
 
     return 0;
 fail: