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 762392 - gtk_drag_source_set_icon_name with empty string puts widget in bad state
gtk_drag_source_set_icon_name with empty string puts widget in bad state
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-02-21 01:25 UTC by Simon Feltman
Modified: 2016-02-21 03:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Python code showing crash (280 bytes, text/plain)
2016-02-21 01:27 UTC, Simon Feltman
Details

Description Simon Feltman 2016-02-21 01:25:21 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
Comment 1 Simon Feltman 2016-02-21 01:27:36 UTC
Created attachment 321765 [details]
Python code showing crash