Commit c15e0db5a9f259e782cf49e50dd1109548bab1fa

Carlos Martín Nieto 2011-03-28T13:58:44

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>

diff --git a/src/tag.c b/src/tag.c
index 7baabab..d90e2de 100644
--- a/src/tag.c
+++ b/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));
 
 	if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0)
-		return error;
+		goto cleanup;
 
 	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';
 
 	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(