8000 Fix leak in git_tag_create_from_buffer by julianmesa-gitkraken · Pull Request #6421 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Fix leak in git_tag_create_from_buffer #6421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/libgit2/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down
0