[vlc-commits] qt4: fix memory leak

Rémi Denis-Courmont git at videolan.org
Tue May 20 13:10:28 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 20 19:07:28 2014 +0800| [798ee1ab7abb3effd5cedbc853f2e765523ce7f7] | committer: Rémi Denis-Courmont

qt4: fix memory leak

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

 modules/gui/qt4/recents.cpp |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
index b45e1a0..0421263 100644
--- a/modules/gui/qt4/recents.cpp
+++ b/modules/gui/qt4/recents.cpp
@@ -217,14 +217,12 @@ int Open::openMRLwithOptions( intf_thread_t* p_intf,
 
     if( options != NULL && options->count() > 0 )
     {
-        ppsz_options = (const char **)malloc( options->count() );
-        if( ppsz_options ) {
-            for( int j = 0; j < options->count(); j++ ) {
-                QString option = colon_unescape( options->at(j) );
-                if( !option.isEmpty() ) {
-                    ppsz_options[j] = qtu(option);
-                    i_options++;
-                }
+        ppsz_options = new const char *[options->count()];
+        for( int j = 0; j < options->count(); j++ ) {
+            QString option = colon_unescape( options->at(j) );
+            if( !option.isEmpty() ) {
+                ppsz_options[j] = qtu(option);
+                i_options++;
             }
         }
     }
@@ -243,6 +241,7 @@ int Open::openMRLwithOptions( intf_thread_t* p_intf,
     if( i_ret == VLC_SUCCESS && b_start && b_playlist )
         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
 
+    delete[] options;
     return i_ret;
 }
 



More information about the vlc-commits mailing list