GNOME Bugzilla – Bug 315549
libgnomeui tries to free statically allocated buffer
Last modified: 2005-09-21 10:18:53 UTC
Steps to reproduce: 1. start gcdmaster 2. select "Create a file image from a CD" 3. go to the section "Recording Options" and select the button "Browse" 4. press "OK" The application crashes. Stack trace:
+ Trace 62771
Other information: I found the following problem in gnome-file-entry.c in the function browse_dialog_ok. The function gtk_file_chooser_get_filename returns pointer that must be freed with g_free(), the function gtk_file_selection_get_filename returns a statically allocated buffer, and there is always used g_free.
Created attachment 51969 [details] [review] This patch fixes the problem.
Maybe, the variable locale_filename_copy is not necessary and it might be enough to do use: - g_free (locale_filename); + if (GTK_IS_FILE_CHOOSER (fentry->fsw)) + g_free (locale_filename_); I used the more complicated solution because I was not sure that GTK_IS_FILE_CHOOSER (fentry->fsw) still returns the same.
Created attachment 52321 [details] [review] different approach I think this should do as well. Gets rid of a gcc warning too: gnome-file-entry.c: In function ‘browse_dialog_ok’: gnome-file-entry.c:462: warning: passing argument 1 of ‘g_free’ discards qualifiers from pointer target type
But this patch introduces one unneeded malloc()/free().
I don't think that's a problem really. Petr's patch also free's a const variable which should be avoided
Commited. Thanks.