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 725014 - g_settings_schema_source_ref should check for NULL pointer
g_settings_schema_source_ref should check for NULL pointer
Status: RESOLVED NOTGNOME
Product: glib
Classification: Platform
Component: gio
2.39.x
Other FreeBSD
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-02-23 20:50 UTC by John F. Carr
Modified: 2017-10-11 12:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Check for NULL in schema_source_ref/unref (586 bytes, patch)
2014-02-23 20:50 UTC, John F. Carr
rejected Details | Review

Description John F. Carr 2014-02-23 20:50:10 UTC
Created attachment 270064 [details] [review]
Check for NULL in schema_source_ref/unref

On a system where I haven't started any of the gnome related services, gsettings will crash (e.g. a simple "gsettings get", or "gsettings foobar" because the crash is before the usage message).  I am on a fresh install of FreeBSD 10.0.  I started X via xinit instead of the normal desktop login process.

The problem is g_settings_schema_source_get_default() returns NULL.  The result passed to g_settings_schema_source_ref() causes a crash trying to increment the reference count.

I see in a comment that NULL is a documented return value from g_settings_schema_source_get_default ("If no schemas are installed, %NULL will be returned.").

I attached a patch to ignore NULL arguments to ref/unref.  Possibly an explicit error and failure would be better.

The patch is relative to 2.39.4.  FreeBSD 10.0 ports is based on 2.36.3.
Comment 1 Philip Withnall 2017-10-11 12:11:01 UTC
Review of attachment 270064 [details] [review]:

That’s incorrect. We don’t want the ref()/unref() functions to ignore programmer errors like this. It looks like the code which is calling get_default() is not handling the NULL return value correctly. From some grepping, I can’t find any such code in GLib, so I assume it’s somewhere else.
Comment 2 Philip Withnall 2017-10-11 12:11:39 UTC
Please fix the code which is calling get_default(). If that’s inside GLib, please reopen this bug report and point out explicitly where it is. Thanks.