mirror of
https://git.proxmox.com/git/libgit2
synced 2025-12-26 14:42:17 +00:00
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>
This commit is contained in:
parent
f2abee47d8
commit
7bc9e2aa2f
@ -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");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user