Commit 01d5d60f authored by Laurent Aimar's avatar Laurent Aimar Committed by Jean-Baptiste Kempf

Fixed potential segfault (on failures) with avcodec audio encoder.

(cherry picked from commit b86867f6)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent cb290dc6
......@@ -956,13 +956,12 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
#if 0
msg_Warn( p_enc, "avcodec_encode_audio: %d", i_out );
#endif
if( i_out < 0 ) break;
p_buffer += p_sys->i_frame_size;
p_sys->i_samples_delay -= p_sys->p_context->frame_size;
i_samples -= p_sys->p_context->frame_size;
if( i_out == 0 ) continue;
if( i_out <= 0 )
continue;
p_block = block_New( p_enc, i_out );
memcpy( p_block->p_buffer, p_sys->p_buffer_out, i_out );
......@@ -981,8 +980,8 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
/* Backup the remaining raw samples */
if( i_samples )
{
memcpy( p_sys->p_buffer + i_samples_delay * 2 *
p_sys->p_context->channels, p_buffer,
memcpy( &p_sys->p_buffer[i_samples_delay * 2 * p_sys->p_context->channels],
p_buffer,
i_samples * 2 * p_sys->p_context->channels );
}
......
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