Commit 08b6794e authored by Philip Withnall's avatar Philip Withnall

gsettings: Fix memory leak on error handling path for g_settings_set()

On the warning/critical error handling paths for g_settings_set(), the
GVariant value was not ref-sunk, and the schema key was leaked. This
won’t affect code in production (unless it’s seriously buggy), but
eliminates some leaks from the error testing paths in the GSettings
Signed-off-by: Philip Withnall's avatarPhilip Withnall <>
parent d6d29a2e
......@@ -1571,6 +1571,7 @@ g_settings_set_value (GSettings *settings,
g_return_val_if_fail (G_IS_SETTINGS (settings), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_variant_ref_sink (value);
g_settings_schema_key_init (&skey, settings->priv->schema, key);
if (!g_settings_schema_key_type_check (&skey, value))
......@@ -1580,22 +1581,23 @@ g_settings_set_value (GSettings *settings,
g_settings_schema_get_id (settings->priv->schema),
g_variant_type_peek_string (skey.type),
g_variant_get_type_string (value));
return FALSE;
if (!g_settings_schema_key_range_check (&skey, value))
success = FALSE;
else if (!g_settings_schema_key_range_check (&skey, value))
g_warning ("g_settings_set_value: value for key '%s' in schema '%s' "
"is outside of valid range",
g_settings_schema_get_id (settings->priv->schema));
return FALSE;
success = FALSE;
success = g_settings_write_to_backend (settings, &skey, value);
success = g_settings_write_to_backend (settings, &skey, value);
g_settings_schema_key_clear (&skey);
g_variant_unref (value);
return success;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment