From d6ef9af82eafef33e117dd61aa3bd51a2464fcc6 Mon Sep 17 00:00:00 2001 From: Yuuki Harano Date: Sat, 21 Nov 2020 17:18:49 +0900 Subject: [PATCH] Fix crash when .schema.xml is not installed * src/pgtkfns.c (parse_resource_key): Check return value. --- src/pgtkfns.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pgtkfns.c b/src/pgtkfns.c index f1ad9ca2725..494cbc72826 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -1861,10 +1861,13 @@ parse_resource_key (const char *res_key, char *setting_key) /* check existence of setting_key */ GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default (); GSettingsSchema *scm = g_settings_schema_source_lookup (ssrc, SCHEMA_ID, FALSE); - if (!g_settings_schema_has_key (scm, setting_key)) { - g_settings_schema_unref (scm); - return NULL; - } + if (!scm) + return NULL; /* *.schema.xml is not installed. */ + if (!g_settings_schema_has_key (scm, setting_key)) + { + g_settings_schema_unref (scm); + return NULL; + } /* create GSettings, and return it */ GSettings *gs = g_settings_new_full (scm, NULL, path); -- 2.39.5