[vlc-commits] Qt: fix memleak

Jean-Baptiste Kempf git at videolan.org
Tue Apr 26 12:24:31 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Apr 26 12:23:44 2011 +0200| [2d9a2010904840aad5c2bef416737cd194d2d387] | committer: Jean-Baptiste Kempf

Qt: fix memleak

And avoid a strdup(""); free() for nothing

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

 modules/gui/qt4/dialogs_provider.cpp |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 31f7826..e73f425 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -681,16 +681,23 @@ void DialogsProvider::loadSubtitlesFile()
     input_item_t *p_item = input_GetItem( p_input );
     if( !p_item ) return;
 
-    char *path = make_path( input_item_GetURI( p_item ) );
-    if( !path ) path = strdup( "" );
-
-    char *sep = strrchr( path, DIR_SEP_CHAR );
-    if( sep ) *sep = '\0';
+    char *path = input_item_GetURI( p_item );
+    char *path2 = NULL;
+    if( path )
+    {
+        path2 = make_path( path );
+        free( path );
+        if( path2 )
+        {
+            char *sep = strrchr( path2, DIR_SEP_CHAR );
+            if( sep ) *sep = '\0';
+        }
+    }
 
     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
                                       EXT_FILTER_SUBTITLE,
-                                      qfu( path ) );
-    free( path );
+                                      qfu( path2 ) );
+    free( path2 );
     foreach( const QString &qsFile, qsl )
     {
         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),



More information about the vlc-commits mailing list