diff options
| author | Carlos Martín Nieto <cmn@elego.de> | 2011-05-31 15:06:22 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@elego.de> | 2011-05-31 17:33:23 +0200 |
| commit | 7bc9e2aa2fe4b554021129fabb8a46b5a33ed4e9 (patch) | |
| tree | e913f7d60220959e044d77e4ca3eebbaa086729e /src | |
| parent | f2abee47d8908cd74f1ca2e46f30c8b9f6a07754 (diff) | |
| download | libgit2-7bc9e2aa2fe4b554021129fabb8a46b5a33ed4e9.tar.gz | |
Guard against double-freeing the current section
If parse_section_header{,_ext} return an error, current_section
doesn't get allocated. Set it to NULL after freeing so we don't try to
free it again.
This fixes part 2-2 of Issue #210.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'src')
| -rw-r--r-- | src/config_file.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/config_file.c b/src/config_file.c index e468a0b88..37e3f1f15 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -808,6 +808,7 @@ static int config_parse(diskfile_backend *cfg_file) case '[': /* section header, new section begins */ free(current_section); + current_section = NULL; error = parse_section_header(cfg_file, ¤t_section); break; @@ -847,8 +848,7 @@ static int config_parse(diskfile_backend *cfg_file) } } - if (current_section) - free(current_section); + free(current_section); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse config"); } |
