Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-12-28 11:23:12 +0400
committerRussell Belfer <rb@github.com>2012-12-28 11:23:12 +0400
commit3865f7f6610563864d8f7a2671229b6fd398cd1b (patch)
tree3778c4306a7b164c182e766e3448fe5a8f54c6ae /src/refs.c
parentf616a36bdd9b1a0f26f399414bbccb434595edff (diff)
Invalid ref name normalization leaked memory
When normalizing a reference name, if there is an error because the name is invalid, then the memory allocated for storing the name could be leaked if the caller was not careful and assumed that the error return code meant that no allocation had occurred. This fixes that by explicitly deallocating the reference name buffer if there is an error in normalizing the name.
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index 35babaa8b..c77e9a56c 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1729,6 +1729,9 @@ cleanup:
GITERR_REFERENCE,
"The given reference name '%s' is not valid", name);
+ if (error && normalize)
+ git_buf_free(buf);
+
return error;
}