Do not leak strings from GKeyFile

The string getters always copy, so we need to free the returned
values.
This commit is contained in:
Emmanuele Bassi 2011-10-11 22:43:54 +01:00
parent 31bee53eb7
commit 7bd5659962
2 changed files with 12 additions and 4 deletions

View File

@ -225,7 +225,7 @@ clutter_config_read_from_key_file (GKeyFile *keyfile)
GError *key_error = NULL;
gboolean bool_value;
gint int_value;
const gchar *str_value;
gchar *str_value;
if (!g_key_file_has_group (keyfile, ENVIRONMENT_GROUP))
return;
@ -294,6 +294,8 @@ clutter_config_read_from_key_file (GKeyFile *keyfile)
else
clutter_text_direction = CLUTTER_TEXT_DIRECTION_LTR;
}
g_free (str_value);
}
#ifdef CLUTTER_ENABLE_DEBUG
@ -301,7 +303,7 @@ static void
clutter_debug_read_from_key_file (GKeyFile *keyfile)
{
GError *key_error = NULL;
const gchar *value;
gchar *value;
if (!g_key_file_has_group (keyfile, DEBUG_GROUP))
return;
@ -319,6 +321,8 @@ clutter_debug_read_from_key_file (GKeyFile *keyfile)
else
g_clear_error (&key_error);
g_free (value);
value = g_key_file_get_value (keyfile, DEBUG_GROUP,
"PaintDebug",
&key_error);
@ -332,6 +336,8 @@ clutter_debug_read_from_key_file (GKeyFile *keyfile)
else
g_clear_error (&key_error);
g_free (value);
value = g_key_file_get_value (keyfile, DEBUG_GROUP,
"PickDebug",
&key_error);
@ -344,6 +350,8 @@ clutter_debug_read_from_key_file (GKeyFile *keyfile)
}
else
g_clear_error (&key_error);
g_free (value);
}
#endif

View File

@ -760,12 +760,12 @@ _clutter_settings_read_from_key_file (ClutterSettings *settings,
case G_TYPE_STRING:
{
const gchar *val;
gchar *val;
val = g_key_file_get_string (keyfile,
SETTINGS_GROUP, p_name,
&key_error);
g_value_set_string (&value, val);
g_value_take_string (&value, val);
}
break;
}