- if (! *database_path && *key_file)
- *database_path = g_key_file_get_value (*key_file, "database", "path", NULL);
+ if (! *database_path && *key_file) {
+ char *path = g_key_file_get_value (*key_file, "database", "path", NULL);
+ if (path) {
+ *database_path = talloc_strdup (ctx, path);
+ g_free (path);
+ }
+ }