[vlc-commits] SSA: do not use memmove

Jean-Baptiste Kempf git at videolan.org
Mon Aug 6 22:37:14 CEST 2012


vlc/vlc-2.0 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Aug  6 00:16:02 2012 +0200| [0d4a5de93522a3457c034f1dd0ea2e86723a291f] | committer: Jean-Baptiste Kempf

SSA: do not use memmove

Ref #7210
(cherry picked from commit 2a8983fe255ba7e531ca9aeeca46617b295955d2)

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

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

 modules/demux/subtitle.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 6c2f9af..aa04ed6 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1003,7 +1003,7 @@ static int  ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle,
     {
         const char *s = TextGetLine( txt );
         int h1, m1, s1, c1, h2, m2, s2, c2;
-        char *psz_text;
+        char *psz_text, *psz_temp;
         char temp[16];
 
         if( !s )
@@ -1046,9 +1046,14 @@ static int  ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle,
                 int i_layer = ( p_sys->i_type == SUB_TYPE_ASS ) ? atoi( temp ) : 0;
 
                 /* ReadOrder, Layer, %s(rest of fields) */
-                snprintf( temp, sizeof(temp), "%d,%d,", i_idx, i_layer );
-                memmove( psz_text + strlen(temp), psz_text, strlen(psz_text)+1 );
-                memcpy( psz_text, temp, strlen(temp) );
+                if( asprintf( &psz_temp, "%d,%d,%s", i_idx, i_layer, psz_text ) == -1 )
+                {
+                    free( psz_text );
+                    return VLC_ENOMEM;
+                }
+
+                free( psz_text );
+                psz_text = psz_temp;
             }
 
             p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +



More information about the vlc-commits mailing list