summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2018-04-17 09:07:38 +0300
committerTanu Kaskinen <tanuk@iki.fi>2018-04-19 14:45:06 +0300
commit8484b63c18741307e77c66d830a2bbde26dc834a (patch)
tree80c7d6374af4c85877212b865f8396ce8ce65517
parentf5ff5d8bf21ebe4d50487079d2f3f3f2b5b446c0 (diff)
downloadpulseaudio-8484b63c18741307e77c66d830a2bbde26dc834a.tar.gz
gsettings: check that children haven't been deleted before using them
According to the documentation of g_settings_list_children(), the listed children may be removed at any time, so g_settings_get_child() may return NULL. This is probably very unlikely to happen in practice, but it's good to check anyway.
-rw-r--r--src/modules/gsettings/gsettings-helper.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/gsettings/gsettings-helper.c b/src/modules/gsettings/gsettings-helper.c
index 36c1df77e..5d1d210ac 100644
--- a/src/modules/gsettings/gsettings-helper.c
+++ b/src/modules/gsettings/gsettings-helper.c
@@ -93,8 +93,14 @@ int main(int argc, char *argv[]) {
group_names = g_settings_list_children(settings);
for (name = group_names; *name; name++) {
- g_signal_connect(g_settings_get_child(settings, *name), "changed",
- (GCallback) module_group_callback, *name);
+ GSettings *child = g_settings_get_child(settings, *name);
+
+ /* The child may have been removed between the
+ * g_settings_list_children() and g_settings_get_child() calls. */
+ if (!child)
+ continue;
+
+ g_signal_connect(child, "changed", (GCallback) module_group_callback, *name);
handle_module_group(*name);
}