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( ...@@ -299,8 +299,10 @@ static int git_tag_create__internal(
} }
if (create_tag_annotation) { 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; return -1;
}
} else } else
git_oid_cpy(oid, git_object_id(target)); 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 ...@@ -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 /** Ensure the tag name doesn't conflict with an already existing
* reference unless overwriting has explicitly been requested **/ * reference unless overwriting has explicitly been requested **/
if (error == 0 && !allow_ref_overwrite) { if (error == 0 && !allow_ref_overwrite) {
git_str_dispose(&ref_name);
git_error_set(GIT_ERROR_TAG, "tag already exists"); git_error_set(GIT_ERROR_TAG, "tag already exists");
return GIT_EEXISTS; return GIT_EEXISTS;
} }
/* write the buffer */ /* write the buffer */
if ((error = git_odb_open_wstream( 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; return error;
}
if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer)))) if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer))))
error = git_odb_stream_finalize_write(oid, stream); 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