mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 15:52:02 +00:00
Don't leak if config parsing fails
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
4e02504f52
commit
9f7f4122cf
11
src/config.c
11
src/config.c
@ -74,15 +74,20 @@ int git_config_open(git_config **cfg_out, const char *path)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*cfg_out = cfg;
|
||||
|
||||
error = gitfo_read_file(&cfg->reader.buffer, cfg->file_path);
|
||||
if(error < GIT_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
/* Initialise the reading position */
|
||||
cfg->reader.read_ptr = cfg->reader.buffer.data;
|
||||
return config_parse(cfg);
|
||||
|
||||
error = config_parse(cfg);
|
||||
if(error < GIT_SUCCESS)
|
||||
git_config_free(cfg);
|
||||
else
|
||||
*cfg_out = cfg;
|
||||
|
||||
return error;
|
||||
|
||||
cleanup:
|
||||
if(cfg->vars)
|
||||
|
Loading…
Reference in New Issue
Block a user