[vlc-commits] codec: subsdec: fix inbuffer size

Francois Cartegnie git at videolan.org
Tue Apr 24 13:17:29 CEST 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Apr 23 16:49:26 2018 +0200| [0ba9a2c09d1cf0140d49956b64e1f132eeeb931c] | committer: Thomas Guillem

codec: subsdec: fix inbuffer size

strlen can't work on wchars

(cherry picked from commit ec9602e466619dad0bfb7a7c963411ed6c88ecf6)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0ba9a2c09d1cf0140d49956b64e1f132eeeb931c
---

 modules/codec/subsdec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index c548ffe8e5..5a63f0b2f2 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -361,7 +361,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     subpicture_t *p_spu = NULL;
-    char *psz_subtitle = NULL;
 
     if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
         return NULL;
@@ -383,7 +382,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Should be resiliant against bad subtitles */
-    psz_subtitle = malloc( p_block->i_buffer + 1 );
+    char *psz_subtitle = malloc( p_block->i_buffer + 1 );
     if( psz_subtitle == NULL )
         return NULL;
     memcpy( psz_subtitle, p_block->p_buffer, p_block->i_buffer );
@@ -400,7 +399,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
     else
     {
-
         if( p_sys->b_autodetect_utf8 )
         {
             if( IsUTF8( psz_subtitle ) == NULL )
@@ -413,7 +411,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
 
         if( !p_sys->b_autodetect_utf8 )
         {
-            size_t inbytes_left = strlen( psz_subtitle );
+            size_t inbytes_left = p_block->i_buffer;
             size_t outbytes_left = 6 * inbytes_left;
             char *psz_new_subtitle = xmalloc( outbytes_left + 1 );
             char *psz_convert_buffer_out = psz_new_subtitle;



More information about the vlc-commits mailing list