[vlc-devel] [PATCH] gui/qt: info_panels: fix leak + potential null-dereference
Filip Roséen
filip at atch.se
Mon Feb 27 07:03:29 CET 2017
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
---
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 aa94d5f487..0789a5bd99 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 );
--
2.11.1
More information about the vlc-devel
mailing list