GNOME Bugzilla – Bug 762392
gtk_drag_source_set_icon_name with empty string puts widget in bad state
Last modified: 2016-02-21 03:46:35 UTC
Using either gtk_drag_source_set_icon_name() or gtk_drag_source_set_icon_stock() with an empty string can lead to crashes. While using an empty string probably isn't particularly useful, it would be nice if the API was a bit friendlier by reporting incorrect usage. This was found because pygobject had a unittest [2] which was calling these methods with empty strings and crashing. The problem may have started after commit [1]. The problem boils down to gtk_image_definition_new_icon_name() returning NULL if its argument is either NULL or an empty string [3]. This NULL return is then stored in the drag source site and attempts to unref the NULL pointer can occur. I think it would be good to add precondition checks to match the underlying calls to gtk_image_definition_new_icon_name/stock(): g_return_if_fail (icon_name[0] != '\0'); [1] https://git.gnome.org/browse/gtk+/commit/?id=1c96b703a684 [2] https://git.gnome.org/browse/pygobject/tree/tests/test_overrides_gtk.py?h=3.19.2#n514 [3] https://git.gnome.org/browse/gtk+/tree/gtk/gtkdragsource.c?h=3.19.9#n413
Created attachment 321765 [details] Python code showing crash