--- gkeyfile.c.0	2011-01-28 08:28:37.000000000 -0500
+++ gkeyfile.c	2011-05-14 22:58:59.425211532 -0400
@@ -139,6 +139,9 @@
                                                                     GKeyFileGroup *group,
                                                                     GList         *pair_node);
 
+static void                  g_key_file_add_key_value_pair     (GKeyFile               *key_file,
+                                                                GKeyFileGroup          *group,
+                                                                GKeyFileKeyValuePair   *pair);
 static void                  g_key_file_add_key                (GKeyFile               *key_file,
 								GKeyFileGroup          *group,
 								const gchar            *key,
@@ -912,11 +915,22 @@
   locale = key_get_locale (key);
 
   if (locale == NULL || g_key_file_locale_is_interesting (key_file, locale))
-    g_key_file_add_key (key_file, key_file->current_group, key, value);
+    {
+      GKeyFileKeyValuePair *pair;
+
+      pair = g_slice_new (GKeyFileKeyValuePair);
+      pair->key = key;
+      pair->value = value;
+
+      g_key_file_add_key_value_pair (key_file, key_file->current_group, pair);
+    }
+  else
+    {
+      g_free (key);
+      g_free (value);
+    }
 
   g_free (locale);
-  g_free (key);
-  g_free (value);
 }
 
 static gchar *
@@ -3330,6 +3344,17 @@
 }
 
 static void
+g_key_file_add_key_value_pair (GKeyFile             *key_file,
+                               GKeyFileGroup        *group,
+                               GKeyFileKeyValuePair *pair)
+{
+  g_hash_table_replace (group->lookup_map, pair->key, pair);
+  group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair);
+  group->has_trailing_blank_line = FALSE;
+  key_file->approximate_size += strlen (pair->key) + strlen (pair->value) + 2;
+}
+
+static void
 g_key_file_add_key (GKeyFile      *key_file,
 		    GKeyFileGroup *group,
 		    const gchar   *key,
@@ -3341,10 +3366,7 @@
   pair->key = g_strdup (key);
   pair->value = g_strdup (value);
 
-  g_hash_table_replace (group->lookup_map, pair->key, pair);
-  group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair);
-  group->has_trailing_blank_line = FALSE;
-  key_file->approximate_size += strlen (key) + strlen (value) + 2;
+  g_key_file_add_key_value_pair (key_file, group, pair);
 }
 
 /**
