summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-05 09:47:16 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-05 09:47:16 +0200
commitb162d97a4f33dbb8d24c2b07ff2f379a074e24ef (patch)
treedc65b73afcba27a7ea84b20d00ec6361560867be
parent074d323f7323f6c57bf409c232c5b92c3d0be634 (diff)
downloadlibgit2-b162d97a4f33dbb8d24c2b07ff2f379a074e24ef.tar.gz
config: plug a couple of leaks
-rw-r--r--src/config_file.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/config_file.c b/src/config_file.c
index afd80d3d5..d6a62b85c 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1381,12 +1381,12 @@ static int parse_variable(struct reader *reader, char **var_name, char **var_val
quote_count = strip_comments(line, 0);
- if (parse_name(var_name, &value_start, reader, line) < 0)
- return -1;
-
/* If there is no value, boolean true is assumed */
*var_value = NULL;
+ if (parse_name(var_name, &value_start, reader, line) < 0)
+ goto on_error;
+
/*
* Now, let's try to parse the value
*/
@@ -1835,7 +1835,10 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
write_data.preg = preg;
write_data.value = value;
- if ((result = config_parse(reader, write_on_section, write_on_variable, write_on_comment, write_on_eof, &write_data)) < 0) {
+ result = config_parse(reader, write_on_section, write_on_variable, write_on_comment, write_on_eof, &write_data);
+ git__free(section);
+
+ if (result < 0) {
git_filebuf_cleanup(&file);
goto done;
}