Mercurial > mplayer.hg
changeset 35944:132d5af113c8
Fix fsTopList_items memory leaks.
Free list's (dup'd) data before freeing the list.
(In order to do so, the few string constants must be g_strdup'd.)
author | ib |
---|---|
date | Thu, 21 Mar 2013 18:10:22 +0000 |
parents | 4d83191b7218 |
children | a8baf85f7b6e |
files | gui/dialog/fileselect.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/dialog/fileselect.c Thu Mar 21 14:07:14 2013 +0000 +++ b/gui/dialog/fileselect.c Thu Mar 21 18:10:22 2013 +0000 @@ -352,7 +352,12 @@ if ( !dir[0] ) nfree( dir ); } - if ( fsTopList_items ) g_list_free( fsTopList_items ); fsTopList_items=NULL; + if ( fsTopList_items ) + { + g_list_foreach(fsTopList_items, (GFunc) g_free, NULL); + g_list_free(fsTopList_items); + fsTopList_items = NULL; + } if ( fsPathTable ) g_hash_table_destroy( fsPathTable ); fsPathTable=g_hash_table_new_full(g_str_hash, g_str_equal, free, free); { unsigned int i, c = 1; @@ -372,10 +377,10 @@ free( dir ); fname = getenv( "HOME" ); if ( fname ) fs_AddPathUtf8(fname, GTK_POS_BOTTOM); - else fsTopList_items=g_list_append( fsTopList_items,"/home" ); - if (stat( "/media",&f ) == 0) fsTopList_items=g_list_append( fsTopList_items,"/media" ); - if (stat( "/mnt",&f ) == 0) fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); - fsTopList_items=g_list_append( fsTopList_items,"/" ); + else fsTopList_items=g_list_append( fsTopList_items,g_strdup( "/home" ) ); + if (stat( "/media",&f ) == 0) fsTopList_items=g_list_append( fsTopList_items,g_strdup( "/media" ) ); + if (stat( "/mnt",&f ) == 0) fsTopList_items=g_list_append( fsTopList_items,g_strdup( "/mnt" ) ); + fsTopList_items=g_list_append( fsTopList_items,g_strdup( "/" ) ); gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); gtk_widget_grab_focus( fsFNameList );