Unverified Commit a7d841a8 by Edward Thomson Committed by GitHub

Merge pull request #6421 from julianmesa-gitkraken/fix-leak-git_tag_create_from_buffer

Fix leak in git_tag_create_from_buffer
parents ad2d3a06 25dd1c93
......@@ -299,8 +299,10 @@ static int git_tag_create__internal(
}
if (create_tag_annotation) {
if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0)
if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0) {
git_str_dispose(&ref_name);
return -1;
}
} else
git_oid_cpy(oid, git_object_id(target));
......@@ -397,14 +399,17 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b
/** Ensure the tag name doesn't conflict with an already existing
* reference unless overwriting has explicitly been requested **/
if (error == 0 && !allow_ref_overwrite) {
git_str_dispose(&ref_name);
git_error_set(GIT_ERROR_TAG, "tag already exists");
return GIT_EEXISTS;
}
/* write the buffer */
if ((error = git_odb_open_wstream(
&stream, odb, strlen(buffer), GIT_OBJECT_TAG)) < 0)
&stream, odb, strlen(buffer), GIT_OBJECT_TAG)) < 0) {
git_str_dispose(&ref_name);
return error;
}
if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer))))
error = git_odb_stream_finalize_write(oid, stream);
......
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