summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Mesa <julian.mesa@gitkraken.com>2022-11-03 14:46:42 +0100
committerJulian Mesa <julian.mesa@gitkraken.com>2022-11-03 14:46:42 +0100
commitc7e8de1712c9ed04fd7d9c737860579d182267ea (patch)
tree11b0961f78f5accd2bd0058c4f4ae2dcef715e72
parenta3841af5eecc6301e87f8302c7fdce6555e39247 (diff)
downloadlibgit2-c7e8de1712c9ed04fd7d9c737860579d182267ea.tar.gz
Fix leak in git_tag_create_from_buffer
If the tag already exists and we are not forcing overwrite we need to free ref_name buffer before return the "tag already exists" error.
-rw-r--r--src/libgit2/tag.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libgit2/tag.c b/src/libgit2/tag.c
index 908adbebf..41689e4c2 100644
--- a/src/libgit2/tag.c
+++ b/src/libgit2/tag.c
@@ -397,6 +397,7 @@ 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;
}