[vlc-commits] SSA: do not use memmove

Jean-Baptiste Kempf git at videolan.org
Thu Aug 9 11:43:08 CEST 2012


vlc/vlc-1.1 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Aug  6 00:16:02 2012 +0200| [8b19a46f11a0b643c7013cd50bf799c4274f527a] | 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-1.1.git/?a=commit;h=8b19a46f11a0b643c7013cd50bf799c4274f527a
---

 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 9bf09d2..e84050a 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1002,7 +1002,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 )
@@ -1045,9 +1045,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