[vlc-devel] commit: Do not realloc a block already given to ffmpeg. (Laurent Aimar )
git version control
git at videolan.org
Thu Oct 8 22:32:21 CEST 2009
vlc | branch: 1.0-bugfix | Laurent Aimar <fenrir at videolan.org> | Thu Oct 8 21:53:31 2009 +0200| [8187223edc735ee7cf311daca68e5e97e7e9380b] | committer: Laurent Aimar
Do not realloc a block already given to ffmpeg.
It avoids a potential segfault after a silent avcodec audio API breakage.
(cherry picked from commit b89c2b2ac347d4a05846342d5995750cc799e1f2)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8187223edc735ee7cf311daca68e5e97e7e9380b
---
modules/codec/avcodec/audio.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 7e552d4..819157c 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -78,6 +78,8 @@ struct decoder_sys_t
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 );
/*****************************************************************************
@@ -306,11 +308,16 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
return NULL;
}
- *pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
- if( !p_block )
- return NULL;
- p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
- memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
+ 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 );
+ if( !p_block )
+ return NULL;
+ p_block->i_buffer -= 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
{
More information about the vlc-devel
mailing list