From 4a3e072ecd0e335c444dc80e49db0e6eaf59cef2 Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Thu, 10 Feb 2011 05:05:53 -0800 Subject: [PATCH] Fix malloc of zero size Caused x264 to fail with some settings on systems that return a NULL pointer for malloc(0), like Solaris. --- common/macroblock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/macroblock.c b/common/macroblock.c index aec5c6a1..8f0b82cd 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: -- 2.40.0