# HG changeset patch # User ib # Date 1363889422 0 # Node ID 132d5af113c8a1931cdaad72f213db7281dbd938 # Parent 4d83191b72188b915a5e41aff6e0797fd62a4b92 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.) diff -r 4d83191b7218 -r 132d5af113c8 gui/dialog/fileselect.c --- 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 );