summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-01-05 17:31:13 -0500
committerJeff King <peff@peff.net>2012-01-05 17:31:13 -0500
commit671bbdd37227d3466ba9a8e1ad0cc6c46c701967 (patch)
treeb29fb2f624c9643ed811d879f88572cc95aa5065 /src
parentf2114d0a35b95efef294f7527dfd64fbef61d993 (diff)
downloadlibgit2-671bbdd37227d3466ba9a8e1ad0cc6c46c701967.tar.gz
reflog_write: don't access free()'d memory
We get the oid of a reference, free the reference, then convert the oid to a string. We need to convert the oid before freeing the memory.
Diffstat (limited to 'src')
-rw-r--r--src/reflog.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/reflog.c b/src/reflog.c
index 84ce52d91..a327975d6 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -237,10 +237,10 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
return error;
}
- git_reference_free(r);
-
git_oid_to_string(new, GIT_OID_HEXSZ+1, oid);
+ git_reference_free(r);
+
error = git_buf_join_n(&log_path, '/', 3,
ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
if (error < GIT_SUCCESS)