Commit b89c2b2a authored by Laurent Aimar's avatar Laurent Aimar

Do not realloc a block already given to ffmpeg.

It avoids a potential segfault after a silent avcodec audio API breakage.
parent 5964d906
...@@ -78,6 +78,8 @@ struct decoder_sys_t ...@@ -78,6 +78,8 @@ struct decoder_sys_t
int64_t i_previous_layout; int64_t i_previous_layout;
}; };
#define BLOCK_FLAG_PRIVATE_REALLOCATED (1 << BLOCK_FLAG_PRIVATE_SHIFT)
static void SetupOutputFormat( decoder_t *p_dec, bool b_trust ); static void SetupOutputFormat( decoder_t *p_dec, bool b_trust );
/***************************************************************************** /*****************************************************************************
...@@ -306,12 +308,17 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -306,12 +308,17 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
return NULL; return NULL;
} }
if( (p_block->i_flags & BLOCK_FLAG_PRIVATE_REALLOCATED) == 0 )
{
*pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE ); *pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
if( !p_block ) if( !p_block )
return NULL; return NULL;
p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE; p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE ); memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
p_block->i_flags |= BLOCK_FLAG_PRIVATE_REALLOCATED;
}
do do
{ {
i_output = __MAX( p_block->i_buffer, p_sys->i_output_max ); i_output = __MAX( p_block->i_buffer, p_sys->i_output_max );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment