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

git version control git at videolan.org
Thu Oct 2 21:13:35 CEST 2008


vlc | branch: 0.9-bugfix | Rémi Duraffort <ivoire at videolan.org> | Wed Oct  1 21:11:57 2008 +0200| [ab73f154bcd8cbeb0f4919a522eb45864074bd32] | committer: Derk-Jan Hartman 

Fix memleak (CID 213)
(cherry picked from commit f7625a5deb7467819830f707a5afc627ad109df3)

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

 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 8a06866..68a8f05 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1838,7 +1838,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( ;; )
@@ -1848,7 +1848,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 )
@@ -1888,8 +1891,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