Commit b2e361cc5e5965d01ef4c033a14ecb61c8523dae

Carlos Martín Nieto 2011-06-16T20:22:05

Plug two leaks in config writing Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

diff --git a/src/config_file.c b/src/config_file.c
index 916b4d0..5199361 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -986,10 +986,19 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
 					break;
 				}
 			} else {
+				int cmp;
+
 				pre_end = cfg->reader.read_ptr;
 				error = parse_variable(cfg, &var_name, &var_value);
-				if (error < GIT_SUCCESS || strcasecmp(var->name, var_name))
+				if (error == GIT_SUCCESS)
+					cmp = strcasecmp(var->name, var_name);
+
+				free(var_name);
+				free(var_value);
+
+				if (error < GIT_SUCCESS || cmp)
 					break;
+
 				post_start = cfg->reader.read_ptr;
 			}
 
@@ -1060,6 +1069,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
 	else
 		error = git_filebuf_commit(&file);
 
+	gitfo_free_buf(&cfg->reader.buffer);
 	return error;
 }