[vlc-commits] commit: Fixed potential segfault (on failures) with avcodec audio encoder. (Laurent Aimar )

git at videolan.org git at videolan.org
Sun May 2 00:37:17 CEST 2010


vlc/vlc-1.1 | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat May  1 20:24:05 2010 +0200| [01d5d60fd59a873397c938cc580637eac6288e39] | committer: Jean-Baptiste Kempf 

Fixed potential segfault (on failures) with avcodec audio encoder.
(cherry picked from commit b86867f6bf0a2cdae0c849e8719a21416cc3c9df)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=01d5d60fd59a873397c938cc580637eac6288e39
---

 modules/codec/avcodec/encoder.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 21a4b6a..78ba958 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -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 );
     }
 



More information about the vlc-commits mailing list