[vlc-commits] SSA: do not use memmove

Jean-Baptiste Kempf git at videolan.org
Mon Aug 6 00:16:43 CEST 2012


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

SSA: do not use memmove

Ref #7210

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

 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 a42c5a8..020ad71 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1009,7 +1009,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 )
@@ -1052,9 +1052,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