diff --git a/goffice/app/go-conf-win32.c b/goffice/app/go-conf-win32.c
index 7cdb333..3f5b77f 100644
--- a/goffice/app/go-conf-win32.c
+++ b/goffice/app/go-conf-win32.c
@@ -52,26 +52,28 @@ go_conf_win32_set (GOConfNode *node, gchar const *key,
 	gchar *last_sep, *path = NULL;
 	HKEY hKey;
 	gboolean ok;
 
 	last_sep = key ? strrchr (key, '/') : NULL;
 	if (last_sep) {
 		path = g_strndup (key, last_sep - key);
 		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
-		g_free (path);
-		if (!ok)
+		if (!ok) {
+			g_free (path);
 			return FALSE;
+		}
 		key = last_sep + 1;
 	} else
 		hKey = node->hKey;
 
 	RegSetValueEx (hKey, key, 0, type, data, size);
 	if (path)
 		RegCloseKey (hKey);
+	g_free (path);
 
 	return TRUE;
 }
 
 static gboolean
 go_conf_win32_get (GOConfNode *node, gchar const *key,
 		   gulong *type, guchar **data, gulong *size,
 		   gboolean do_realloc, gint *ret_code)
@@ -80,33 +82,35 @@ go_conf_win32_get (GOConfNode *node, gchar const *key,
 	HKEY hKey;
 	LONG ret;
 	gboolean ok;
 
 	last_sep = key ? strrchr (key, '/') : NULL;
 	if (last_sep) {
 		path = g_strndup (key, last_sep - key);
 		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
-		g_free (path);
-		if (!ok)
+		if (!ok) {
 			return FALSE;
+			g_free (path);
+		}
 		key = last_sep + 1;
 	} else
 		hKey = node->hKey;
 
 	if (!*data && do_realloc) {
 		RegQueryValueEx (hKey, key, NULL, type, NULL, size);
 		*data = g_new (guchar, *size);
 	}
 	while ((ret = RegQueryValueEx (hKey, key, NULL,
 				       type, *data, size)) == ERROR_MORE_DATA &&
 	       do_realloc)
 		*data = g_realloc (*data, *size);
 	if (path)
 		RegCloseKey (hKey);
+	g_free (path);
 	if (ret_code)
 		*ret_code = ret;
 
 	return ret == ERROR_SUCCESS;
 }
 
 static void
 go_conf_win32_clone (HKEY hSrcKey, gchar *key, HKEY hDstKey, gchar *buf1, gchar *buf2, gchar *buf3)
