[vlc-devel] [PATCH] Fix a memleak in vlc_meta_delete().

Adrien Maglo magsoft at videolan.org
Mon Sep 29 18:25:46 CEST 2008


Indeed vlc_meta_AddExtra() allocates memory using strdup() which is never free.
---
 include/vlc_meta.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/vlc_meta.h b/include/vlc_meta.h
index a2abee0..fe8d940 100644
--- a/include/vlc_meta.h
+++ b/include/vlc_meta.h
@@ -117,8 +117,14 @@ static inline vlc_meta_t *vlc_meta_New( void )
 static inline void vlc_meta_Delete( vlc_meta_t *m )
 {
     int i;
+    struct vlc_dictionary_entry_t *p_entry;
     for( i = 0; i < VLC_META_TYPE_COUNT ; i++ )
         free( m->ppsz_meta[i] );
+    /* Free all dictionory values (allocated by strdup in vlc_meta_AddExtra) */
+    for( i = 0; i < m->extra_tags.i_size; i++ )
+        for( p_entry = m->extra_tags.p_entries[i]; p_entry; p_entry = p_entry->p_next )
+            free( p_entry->p_value );
+    /* Clear dictionary */
     vlc_dictionary_clear( &m->extra_tags );
     free( m );
 }
-- 
1.5.6.3




More information about the vlc-devel mailing list