Commit 3d23b74af75bc35b3676c1a7fc1f5a0299c9f4ee

Carlos Martín Nieto 2011-03-29T13:50:37

Free the config var hash contents in git_config_free Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

diff --git a/src/config.c b/src/config.c
index 22ba5f5..5c500c4 100644
--- a/src/config.c
+++ b/src/config.c
@@ -35,6 +35,15 @@
  ***********************/
 static int config_parse(git_config *cfg_file);
 static int parse_variable(git_config *cfg, const char *section_name, const char *line);
+void git_config_free(git_config *cfg);
+
+static void cvar_free(git_cvar *var)
+{
+	if(var->type == GIT_VAR_STR)
+		free(var->value.string);
+
+	free(var);
+}
 
 uint32_t config_table_hash(const void *key, int hash_id)
 {
@@ -101,10 +110,18 @@ int git_config_open(git_config **cfg_out, const char *path)
 
 void git_config_free(git_config *cfg)
 {
+	git_cvar *var;
+	const void *_unused;
+
 	if (cfg == NULL)
 		return;
 
 	free(cfg->file_path);
+
+	GIT_HASHTABLE_FOREACH(cfg->vars, _unused, var,
+		cvar_free(var);
+	);
+
 	git_hashtable_free(cfg->vars);
 	gitfo_free_buf(&cfg->reader.buffer);