[vlc-devel] [PATCH] lua/vlc: vlc_sd_probe_Open: fix memory-leak

Filip Roséen filip at atch.se
Fri Nov 18 03:59:59 CET 2016


vlc_dictionary_all_keys requires the caller to not only release the
returned value, but also the entities this value refers to; these
changes fixes a memory-leak due to not doing the latter.
---
 modules/lua/vlc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 0a1cc70..70af88e 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -654,12 +654,16 @@ static int vlc_sd_probe_Open( vlc_object_t *obj )
     char **names = vlc_dictionary_all_keys( &name_d );
     if( names != NULL )
     {
-        for( char **name = names; *name != NULL; name++ )
+        for( char **name = names; *name; ++name )
         {
             r = vlclua_probe_sd( obj, *name );
             if( r != VLC_PROBE_CONTINUE )
                 break;
         }
+
+        for( char **name = names; *name; ++name )
+            free( *name );
+
         free( names );
     }
     vlc_dictionary_clear( &name_d, NULL, NULL );
-- 
2.10.2



More information about the vlc-devel mailing list