Skip to content

gsettings: check param exists before setting value

Fushan Wen requested to merge work/fuf/checkparam into master

If a param name doesn't exist in a schema, g_settings_set_value will crash the program, so make sure the param name exists before setting a value.

Backtrace
Stack trace of thread 11690:
                #0  0x00007fb46706ed37 g_log_structured_array (libglib-2.0.so.0 + 0x5fd37)
                #1  0x00007fb46706f15e g_log_default_handler (libglib-2.0.so.0 + 0x6015e)
                #2  0x00007fb46706f3c7 g_logv (libglib-2.0.so.0 + 0x603c7)
                #3  0x00007fb46706f65f g_log (libglib-2.0.so.0 + 0x6065f)
                #4  0x00007fb46030d5d9 g_settings_schema_get_value (libgio-2.0.so.0 + 0x1015d9)
                #5  0x00007fb46030dbe3 g_settings_schema_key_init (libgio-2.0.so.0 + 0x101be3)
                #6  0x00007fb4603125dc g_settings_set_value (libgio-2.0.so.0 + 0x1065dc)
                #7  0x00007fb45805f088 _ZN15GSettingsEditor8setValueERK7QStringRK8QVariantS2_ (gtkconfig.so + 0x1d088)
                #8  0x00007fb45805038a _ZNK9GtkConfig9setColorsEv (gtkconfig.so + 0xe38a)
                #9  0x00007fb458050c23 _ZN9GtkConfigC2EP7QObjectRK5QListI8QVariantE (gtkconfig.so + 0xec23)
                #10 0x00007fb458051d29 _ZN14KPluginFactory14createInstanceI9GtkConfig7QObjectEEPS2_P7QWidgetS3_RK5QListI8QVariantE (gtkconfig.so + 0xfd29)
                #11 0x00007fb468e3a393 _ZN14KPluginFactory6createEPKcP7QWidgetP7QObjectRK5QListI8QVariantERK7QString (libKF5CoreAddons.so.5 + 0x5f393)
                #12 0x000055bdd625103e _ZN14KPluginFactory6createI10KDEDModuleEEPT_P7QObjectRK5QListI8QVariantE (kded5 + 0xa03e)
                #13 0x000055bdd625388e _ZN4Kded11initModulesEv (kded5 + 0xc88e)
                #14 0x000055bdd62553b8 _ZN4Kded12recreateDoneEv (kded5 + 0xe3b8)
                #15 0x000055bdd624e4e6 main (kded5 + 0x74e6)
                #16 0x00007fb467a2caf0 __libc_start_call_main (libc.so.6 + 0x27af0)
                #17 0x00007fb467a2cbb9 __libc_start_main_impl (libc.so.6 + 0x27bb9)
                #18 0x000055bdd624eb75 _start (kded5 + 0x7b75)

@lucabacci

Merge request reports

Loading