Commit 5903aa2b by Vicent Martí

Merge pull request #318 from schu/ref-fix-leak

reference_rename: make sure old_name gets freed
parents b08683ff ca6f203c
......@@ -1290,7 +1290,7 @@ int git_reference_set_target(git_reference *ref, const char *target)
int git_reference_rename(git_reference *ref, const char *new_name, int force)
{
int error;
char *old_name = git__strdup(ref->name);
char *old_name = NULL;
char aux_path[GIT_PATH_MAX];
char normalized[GIT_REFNAME_MAX];
......@@ -1328,6 +1328,8 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
* the new reference, e.g. when renaming foo/bar -> foo.
*/
old_name = git__strdup(ref->name);
if (ref->type & GIT_REF_SYMBOLIC) {
if ((target_ref = git_reference_target(ref)) == NULL)
goto cleanup;
......
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