[vlc-devel] commit: Fix memleak (CID 213) ( Rémi Duraffort )

git version control git at videolan.org
Wed Oct 1 21:12:37 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Oct  1 21:11:57 2008 +0200| [f7625a5deb7467819830f707a5afc627ad109df3] | committer: Rémi Duraffort 

Fix memleak (CID 213)

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

 modules/demux/subtitle.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index a4e4d83..d814e00 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1830,7 +1830,7 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
     VLC_UNUSED( i_idx );
     demux_sys_t *p_sys = p_demux->p_sys;
     text_t      *txt = &p_sys->txt;
-    char *psz_text;
+    char *psz_text = NULL;
     char psz_end[12]= "", psz_begin[12] = "";
 
     for( ;; )
@@ -1840,7 +1840,10 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
         const char *s = TextGetLine( txt );
 
         if( !s )
+        {
+            free( psz_text );
             return VLC_EGENERIC;
+        }
 
         psz_text = malloc( strlen( s ) + 1 );
         if( !psz_text )
@@ -1880,8 +1883,11 @@ static int ParseRealText( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
             break;
         }
         /* Line is not recognized */
-        else continue;
-        free( psz_text );
+        else
+        {
+            free( psz_text );
+            continue;
+        }
     }
 
     /* Get the following Lines */




More information about the vlc-devel mailing list