[glib] GSettings: Don't free value before using its type
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSettings: Don't free value before using its type
- Date: Sun, 27 Jun 2010 14:13:22 +0000 (UTC)
commit 795d2bf8cf13d03214af3eb857d235c2917f9945
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Jun 27 10:11:45 2010 -0400
GSettings: Don't free value before using its type
Fix a bug where the type from g_variant_get_type() was used after
freeing the variant. This works for base types (since they are cached
and live forever) but not for arrays (where the bug was first seen).
gio/gsettings-tool.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c
index d3501f3..04d95e0 100644
--- a/gio/gsettings-tool.c
+++ b/gio/gsettings-tool.c
@@ -157,7 +157,7 @@ handle_set (gint *argc,
gchar *key;
gchar *value;
GSettings *settings;
- GVariant *v;
+ GVariant *v, *default_v;
const GVariantType *type;
GOptionContext *context;
GOptionEntry entries[] = {
@@ -201,12 +201,12 @@ handle_set (gint *argc,
else
settings = g_settings_new (schema);
- v = g_settings_get_value (settings, key);
- type = g_variant_get_type (v);
- g_variant_unref (v);
+ default_v = g_settings_get_value (settings, key);
+ type = g_variant_get_type (default_v);
error = NULL;
v = g_variant_parse (type, value, NULL, NULL, &error);
+ g_variant_unref (default_v);
if (v == NULL)
{
g_printerr ("%s\n", error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]