From: Anton Mitrofanov Date: Thu, 10 Feb 2011 13:05:53 +0000 (-0800) Subject: Fix malloc of zero size X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=1f69cb33c1dc6992fbe4092d7aa906534acdcac8;p=x264.git Fix malloc of zero size Caused x264 to fail with some settings on systems that return a NULL pointer for malloc(0), like Solaris. --- diff --git a/common/macroblock.c b/common/macroblock.c index e559ab17..24c2af92 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -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: