diff options
| author | schu <schu-github@schulog.org> | 2011-07-12 17:53:22 +0200 |
|---|---|---|
| committer | schu <schu-github@schulog.org> | 2011-07-12 17:59:22 +0200 |
| commit | ca6f203c595e68ea5bc868cd2e749aa1d30f9785 (patch) | |
| tree | 1ee7f4972149e3955bfd3f6282a973e411491205 /src/refs.c | |
| parent | b08683ffb2146bb164108a525a9f0a9972f7ed8b (diff) | |
| download | libgit2-ca6f203c595e68ea5bc868cd2e749aa1d30f9785.tar.gz | |
reference_rename: make sure old_name gets freed
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'src/refs.c')
| -rw-r--r-- | src/refs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/refs.c b/src/refs.c index 843c69a32..78bab885e 100644 --- a/src/refs.c +++ b/src/refs.c @@ -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; |
