GNOME Bugzilla – Bug 725014
g_settings_schema_source_ref should check for NULL pointer
Last modified: 2017-10-11 12:11:39 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.
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.
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.