diff options
author | Ashok P. Nadkarni <apnmbx-wits@yahoo.com> | 2022-04-13 16:09:58 +0530 |
---|---|---|
committer | Ashok P. Nadkarni <apnmbx-wits@yahoo.com> | 2022-04-13 16:09:58 +0530 |
commit | f0167095401cb7fcfa1e0b70436ed561dc3918d7 (patch) | |
tree | 789fce0578566e1a14cc39c01215a67381dde339 | |
parent | 182d0d1ee933de46bf0b5a6ec269bafa77aba9a2 (diff) | |
download | libgit2-f0167095401cb7fcfa1e0b70436ed561dc3918d7.tar.gz |
Bug #6272 - fix crash in git_describe_commit.
When the passed object fails to be peeled into a commit pointer,
the cleanup code still tries to free the (uninitialized) pointer.
-rw-r--r-- | src/describe.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/describe.c b/src/describe.c index 1033eac50..cae68bdd4 100644 --- a/src/describe.c +++ b/src/describe.c @@ -652,7 +652,7 @@ int git_describe_commit( { struct get_name_data data; struct commit_name *name; - git_commit *commit; + git_commit *commit = NULL; int error = -1; git_describe_options normalized; @@ -698,7 +698,8 @@ int git_describe_commit( goto cleanup; cleanup: - git_commit_free(commit); + if (commit != NULL) + git_commit_free(commit); git_oidmap_foreach_value(data.names, name, { git_tag_free(name->tag); |