Commit 7bc9e2aa by Carlos Martín Nieto

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>
parent f2abee47
......@@ -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, &current_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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment