GNOME Bugzilla – Bug 727687
segfault: gtk_entry_set_text calls strcmp with a NULL pointer
Last modified: 2014-04-12 07:49:38 UTC
This is with gtk-3.12.0 and glib-2.40.0 compiled with debug symbols. I'm seeing that evolution segfaults when starting.
The backtrace (attached here) shows that gtk_entry_set_text calls strcmp with the *text pointer being null. Checking the code it shouldn't happen because there's a g_return_if_fail (text != NULL).
In the API it is stated that g_return_if_fail and g_return_vail_if_fail are not checked if G_DISABLE_CHECKS is set at compile time. This happens when --enable-debug=no is explicitly set.
It would appear this is not the expected behavior because those checks are used in gtk and may lead to segfaults within the gtk itself (the code in gtk_entry_set_text in the gtk/gtkentry.c file relies on g_return_if_fail to check if strcmp will be called with a NULL pointer or not).
The attached simple patch (git format patch) addresses that in the configure.ac.
Created attachment 273648 [details] [review]
Fix of -DG_DISABLE_CHECKS
Calling gtk_entry_set_text with a NULL text is a bug in evolution and needs to be fixed there.
I'd say the gtk_entry_set_text routine checks if the val is NULL and if so that routine returns, thus it is expected to call it with a NULL value and if that happens gtk_entry_set_text correctly returns.
Adding -DG_DISABLE_CHECKS makes g_return_[val_]if_fail not to be checked. That makes gtk_entry_set_text to behave different if -DG_DISABLE_CHECKS is provided or not, leading to a segfault of gtk even if gtk_entry_set_text has an explicit check of the text argument.
Because of that I'd say even that evolution is not right calling gtk_entry_set_text with a NULL argument I'd say that gtk shouldn't segfault when text is NULL, there's already a protection to check that.