[vlc-commits] gui/qt: info_panels: fix leak + potential null-dereference

Filip Roséen git at videolan.org
Mon Feb 27 12:02:29 CET 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Mon Feb 27 07:03:29 2017 +0100| [60b9fae6946e9576c434f8382df2a8319c56ed5c] | committer: Hugo Beauzée-Luyssen

gui/qt: info_panels: fix leak + potential null-dereference

vlc_meta_CopyExtraNames returns a pointer to a dynamically allocated
resource, this should of course be cleaned up after it is used; we
should also not assume that the function is always successful, but
instead check to see that we really have data to use in order to
prevent *undefined-behavior*.

CID: #1401545

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 modules/gui/qt/components/info_panels.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/info_panels.cpp b/modules/gui/qt/components/info_panels.cpp
index aa94d5f..0789a5b 100644
--- a/modules/gui/qt/components/info_panels.cpp
+++ b/modules/gui/qt/components/info_panels.cpp
@@ -440,11 +440,15 @@ void ExtraMetaPanel::update( input_item_t *p_item )
         add_row( VLC_META_DISCNUMBER, psz_disc );
 
     char ** ppsz_keys = vlc_meta_CopyExtraNames( p_meta );
-
-    for( int i = 0; ppsz_keys[i]; ++i )
+    if( ppsz_keys )
     {
-        add_row( ppsz_keys[i], vlc_meta_GetExtra( p_meta, ppsz_keys[i] ) );
-        free( ppsz_keys[i] );
+        for( int i = 0; ppsz_keys[i]; ++i )
+        {
+            add_row( ppsz_keys[i], vlc_meta_GetExtra( p_meta, ppsz_keys[i] ) );
+            free( ppsz_keys[i] );
+        }
+
+        free( ppsz_keys );
     }
 
     extraMeta->verticalHeader()->resizeSections( QHeaderView::ResizeToContents );



More information about the vlc-commits mailing list