Commit 209f2eaf authored by Laurent Aimar's avatar Laurent Aimar

* transcode: fix a potential segfault.

parent 6691d5b2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transcode.c * transcode.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: transcode.c,v 1.17 2003/05/22 20:45:25 hartman Exp $ * $Id: transcode.c,v 1.18 2003/06/25 21:47:05 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -601,15 +601,15 @@ static int transcode_audio_ffmpeg_new ( sout_stream_t *p_stream, sout_stream_i ...@@ -601,15 +601,15 @@ static int transcode_audio_ffmpeg_new ( sout_stream_t *p_stream, sout_stream_i
} }
id->i_buffer_in = AVCODEC_MAX_AUDIO_FRAME_SIZE; id->i_buffer_in = 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE;
id->i_buffer_in_pos = 0; id->i_buffer_in_pos = 0;
id->p_buffer_in = malloc( id->i_buffer_in ); id->p_buffer_in = malloc( id->i_buffer_in );
id->i_buffer = AVCODEC_MAX_AUDIO_FRAME_SIZE; id->i_buffer = 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE;
id->i_buffer_pos = 0; id->i_buffer_pos = 0;
id->p_buffer = malloc( id->i_buffer ); id->p_buffer = malloc( id->i_buffer );
id->i_buffer_out = AVCODEC_MAX_AUDIO_FRAME_SIZE; id->i_buffer_out = 2 * AVCODEC_MAX_AUDIO_FRAME_SIZE;
id->i_buffer_out_pos = 0; id->i_buffer_out_pos = 0;
id->p_buffer_out = malloc( id->i_buffer_out ); id->p_buffer_out = malloc( id->i_buffer_out );
...@@ -635,6 +635,8 @@ static void transcode_audio_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_ ...@@ -635,6 +635,8 @@ static void transcode_audio_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_
static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_id_t *id, static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *in, sout_buffer_t **out ) sout_buffer_t *in, sout_buffer_t **out )
{ {
vlc_bool_t b_again = VLC_FALSE;
*out = NULL; *out = NULL;
/* gather data into p_buffer_in */ /* gather data into p_buffer_in */
...@@ -654,6 +656,8 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_ ...@@ -654,6 +656,8 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_
in->i_size ); in->i_size );
id->i_buffer_in_pos += in->i_size; id->i_buffer_in_pos += in->i_size;
do
{
/* decode as many data as possible */ /* decode as many data as possible */
if( id->ff_dec ) if( id->ff_dec )
{ {
...@@ -689,6 +693,13 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_ ...@@ -689,6 +693,13 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_
id->i_buffer_in_pos = 0; id->i_buffer_in_pos = 0;
break; break;
} }
if( id->i_buffer_pos >= AVCODEC_MAX_AUDIO_FRAME_SIZE )
{
/* buffer full */
b_again = VLC_TRUE;
break;
}
} }
} }
else else
...@@ -813,6 +824,8 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_ ...@@ -813,6 +824,8 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream, sout_stream_
sout_BufferChain( out, p_out ); sout_BufferChain( out, p_out );
} }
} while( b_again );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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