gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Feb 20 15:17:57 EST 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/6983adb1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/587cc4b9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/606fc455 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2b7043b4 (commit)



commit 6983adb14a389c13f828bae4f485b4748a8ead24
Merge: 2b7043b4ba 587cc4b91e
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Feb 20 12:10:14 2026 -0800

    Merge Noerr Noah's 'fix-gsettings-segfault' into stable.


commit 587cc4b91e4dfa823f10bbb8de9374d320a5a416
Author: Noah <8070871+Noerr at users.noreply.github.com>
Date:   Thu Feb 12 09:10:02 2026 -0800

    Use g_return_val_if_fail / g_return_if_fail for NULL guards
    
    Replace verbose if-block NULL checks with idiomatic GLib
    precondition macros, per review feedback.

diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index ab8e23349d..951969c2fe 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -105,20 +105,10 @@ static GSettings * gnc_gsettings_get_settings_obj (const gchar *schema_str)
     auto full_name_str = normalize_schema_name (schema_str);
     auto full_name = full_name_str.c_str();
     auto schema_source {g_settings_schema_source_get_default()};
-    if (!schema_source)
-    {
-        PWARN ("No GSettings schema source available; cannot access schema %s", full_name);
-        LEAVE("");
-        return nullptr;
-    }
+    g_return_val_if_fail(schema_source, nullptr);
 
     auto schema {g_settings_schema_source_lookup(schema_source, full_name, true)};
-    if (!schema)
-    {
-        PWARN ("GSettings schema %s not found", full_name);
-        LEAVE("");
-        return nullptr;
-    }
+    g_return_val_if_fail(schema, nullptr);
 
     auto gset = g_settings_new_full (schema, nullptr, nullptr);
     DEBUG ("Created gsettings object %p for schema %s", gset, full_name);
@@ -559,11 +549,7 @@ gnc_settings_dump_schema_paths (void)
     gchar **non_relocatable;
 
     auto schema_source {g_settings_schema_source_get_default()};
-    if (!schema_source)
-    {
-        PWARN ("No GSettings schema source available; cannot dump schema paths");
-        return;
-    }
+    g_return_if_fail(schema_source);
 
     g_settings_schema_source_list_schemas (schema_source, true,
                                            &non_relocatable, nullptr);

commit 606fc455820457a7892bc5fda41828a7b7ffa8b7
Author: Claude <noreply at anthropic.com>
Date:   Mon Feb 9 18:35:56 2026 +0000

    Fix segfault in gnc_gsettings_get_settings_obj when GSettings schemas are not installed
    
    Add NULL guards before dereferencing return values from GLib calls to prevent
    segmentation faults when GSettings schemas are missing (e.g., in library-only builds).
    
    The crash occurred when g_settings_schema_source_get_default() returned NULL
    and was passed directly to g_settings_schema_source_lookup(), causing a NULL
    pointer dereference. The existing G_IS_SETTINGS check came too late.
    
    Changes:
    - Add NULL check for schema_source before using it
    - Add NULL check for schema before calling g_settings_new_full()
    - Add NULL guard in gnc_settings_dump_schema_paths() for consistency
    - All callers already handle NULL returns via G_IS_SETTINGS checks
    
    Fixes: https://bugs.gnucash.org/show_bug.cgi?id=799740
    
    https://claude.ai/code/session_01Cdnp3XkAQ29hG1eCxUSAUw

diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index 40aac9dd71..ab8e23349d 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -105,7 +105,21 @@ static GSettings * gnc_gsettings_get_settings_obj (const gchar *schema_str)
     auto full_name_str = normalize_schema_name (schema_str);
     auto full_name = full_name_str.c_str();
     auto schema_source {g_settings_schema_source_get_default()};
+    if (!schema_source)
+    {
+        PWARN ("No GSettings schema source available; cannot access schema %s", full_name);
+        LEAVE("");
+        return nullptr;
+    }
+
     auto schema {g_settings_schema_source_lookup(schema_source, full_name, true)};
+    if (!schema)
+    {
+        PWARN ("GSettings schema %s not found", full_name);
+        LEAVE("");
+        return nullptr;
+    }
+
     auto gset = g_settings_new_full (schema, nullptr, nullptr);
     DEBUG ("Created gsettings object %p for schema %s", gset, full_name);
 
@@ -545,6 +559,12 @@ gnc_settings_dump_schema_paths (void)
     gchar **non_relocatable;
 
     auto schema_source {g_settings_schema_source_get_default()};
+    if (!schema_source)
+    {
+        PWARN ("No GSettings schema source available; cannot dump schema paths");
+        return;
+    }
+
     g_settings_schema_source_list_schemas (schema_source, true,
                                            &non_relocatable, nullptr);
 



Summary of changes:
 libgnucash/app-utils/gnc-gsettings.cpp | 6 ++++++
 1 file changed, 6 insertions(+)



More information about the gnucash-changes mailing list