After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 315549 - libgnomeui tries to free statically allocated buffer
libgnomeui tries to free statically allocated buffer
Status: RESOLVED FIXED
Product: libgnomeui
Classification: Deprecated
Component: general
2.12.x
Other All
: High critical
: future
Assigned To: libgnomeui maintainers
libgnomeui maintainers
Depends on:
Blocks:
 
 
Reported: 2005-09-08 15:44 UTC by Petr Mladek
Modified: 2005-09-21 10:18 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
This patch fixes the problem. (992 bytes, patch)
2005-09-08 15:45 UTC, Petr Mladek
none Details | Review
different approach (1004 bytes, patch)
2005-09-16 19:16 UTC, Kjartan Maraas
committed Details | Review

Description Petr Mladek 2005-09-08 15:44:56 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:
  • #0 raise
    from /lib64/tls/libc.so.6
  • #1 abort
    from /lib64/tls/libc.so.6
  • #2 __libc_message
    from /lib64/tls/libc.so.6
  • #3 malloc_printerr
    from /lib64/tls/libc.so.6
  • #4 free
    from /lib64/tls/libc.so.6
  • #5 browse_dialog_ok
    at gnome-file-entry.c line 462
  • #6 g_closure_invoke
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #7 g_signal_stop_emission
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #8 g_signal_emit_valist
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #9 g_signal_emit
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #10 gtk_button_get_alignment
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #11 g_closure_invoke
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #12 g_signal_stop_emission
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #13 g_signal_emit_valist
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #14 g_signal_emit
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #15 gtk_button_set_relief
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #16 gtk_marshal_VOID__UINT_STRING
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #17 g_closure_invoke
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #18 g_signal_stop_emission
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #19 g_signal_emit_valist
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #20 g_signal_emit
    from /opt/gnome/lib64/libgobject-2.0.so.0
  • #21 gtk_widget_activate
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #22 gtk_propagate_event
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #23 gtk_main_do_event
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #24 gdk_screen_get_setting
    from /opt/gnome/lib64/libgdk-x11-2.0.so.0
  • #25 g_main_context_dispatch
    from /opt/gnome/lib64/libglib-2.0.so.0
  • #26 g_main_context_check
    from /opt/gnome/lib64/libglib-2.0.so.0
  • #27 g_main_loop_run
    from /opt/gnome/lib64/libglib-2.0.so.0
  • #28 gtk_main
    from /opt/gnome/lib64/libgtk-x11-2.0.so.0
  • #29 main


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.
Comment 1 Petr Mladek 2005-09-08 15:45:56 UTC
Created attachment 51969 [details] [review]
This patch fixes the problem.
Comment 2 Petr Mladek 2005-09-08 15:56:54 UTC
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.
Comment 3 Kjartan Maraas 2005-09-16 19:16:51 UTC
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
Comment 4 Stanislav Brabec 2005-09-19 12:04:30 UTC
But this patch introduces one unneeded malloc()/free().
Comment 5 Kjartan Maraas 2005-09-20 07:38:46 UTC
I don't think that's a problem really. Petr's patch also free's a const variable
which should be avoided
Comment 6 Kjartan Maraas 2005-09-21 10:18:53 UTC
Commited. Thanks.