[vlc-commits] subtitle: Fix potential memory leaks

Hugo Beauzée-Luyssen git at videolan.org
Wed May 3 12:39:41 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed May  3 12:34:56 2017 +0200| [c2e45c4ecf2d51820dfe095d89e8b9379c8df4ca] | committer: Hugo Beauzée-Luyssen

subtitle: Fix potential memory leaks

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

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

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 9726bc26bb..9b417ce454 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1689,7 +1689,7 @@ static int ParseJSS( vlc_object_t *p_obj, subs_properties_t *p_props,
                      text_t *txt, subtitle_t *p_subtitle, size_t i_idx )
 {
     VLC_UNUSED( i_idx );
-    char         *psz_text, *psz_orig;
+    char         *psz_text, *psz_orig = NULL;
     char         *psz_text2, *psz_orig2;
     int h1, h2, m1, m2, s1, s2, f1, f2;
 
@@ -1705,6 +1705,7 @@ static int ParseJSS( vlc_object_t *p_obj, subs_properties_t *p_props,
     /* Parse the main lines */
     for( ;; )
     {
+        free( psz_orig );
         const char *s = TextGetLine( txt );
         if( !s )
             return VLC_EGENERIC;
@@ -1795,16 +1796,10 @@ static int ParseJSS( vlc_object_t *p_obj, subs_properties_t *p_props,
                 sscanf( &psz_text[shift], "%d", &p_props->jss.i_time_resolution );
                 break;
             }
-            free( psz_orig );
-            continue;
-        }
-        else
-            /* Unkown type line, probably a comment */
-        {
-            free( psz_orig );
-            continue;
         }
     }
+    free( psz_orig );
+    psz_orig = NULL;
 
     while( psz_text[ strlen( psz_text ) - 1 ] == '\\' )
     {



More information about the vlc-commits mailing list