mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 22:39:38 +00:00
Fix memory leak in parse_tag_buffer
Free the allocated memory if the signature parsing reports an error. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
f3cf7f6df1
commit
c15e0db5a9
10
src/tag.c
10
src/tag.c
@ -142,7 +142,7 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
|
|||||||
tag->tagger = git__malloc(sizeof(git_signature));
|
tag->tagger = git__malloc(sizeof(git_signature));
|
||||||
|
|
||||||
if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0)
|
if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0)
|
||||||
return error;
|
goto cleanup;
|
||||||
|
|
||||||
text_len = buffer_end - ++buffer;
|
text_len = buffer_end - ++buffer;
|
||||||
|
|
||||||
@ -151,6 +151,14 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
|
|||||||
tag->message[text_len] = '\0';
|
tag->message[text_len] = '\0';
|
||||||
|
|
||||||
return GIT_SUCCESS;
|
return GIT_SUCCESS;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if(tag->tag_name)
|
||||||
|
free(tag->tag_name);
|
||||||
|
if(tag->tagger)
|
||||||
|
git_signature_free(tag->tagger);
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_tag_create_o(
|
int git_tag_create_o(
|
||||||
|
Loading…
Reference in New Issue
Block a user