[vlc-commits] codec: substx3g: use strndup

Francois Cartegnie git at videolan.org
Tue Jan 2 17:19:05 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan  2 16:54:02 2018 +0100| [a874fbbfd7522733847ada2c5970290c90b9c64d] | committer: Francois Cartegnie

codec: substx3g: use strndup

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

 modules/codec/substx3g.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/modules/codec/substx3g.c b/modules/codec/substx3g.c
index cb651112d3..148f065111 100644
--- a/modules/codec/substx3g.c
+++ b/modules/codec/substx3g.c
@@ -336,11 +336,9 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
     }
     else
     {
-        psz_subtitle = malloc( i_psz_bytelength + 1 );
+        psz_subtitle = strndup( (const char*) p_pszstart, i_psz_bytelength );
         if ( !psz_subtitle )
             return VLCDEC_SUCCESS;
-        memcpy( psz_subtitle, p_pszstart, i_psz_bytelength );
-        psz_subtitle[ i_psz_bytelength ] = '\0';
     }
     p_buf += i_psz_bytelength + sizeof(uint16_t);
 



More information about the vlc-commits mailing list