Commit 671bbdd3 by Jeff King

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.
parent f2114d0a
...@@ -237,10 +237,10 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old, ...@@ -237,10 +237,10 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
return error; return error;
} }
git_reference_free(r);
git_oid_to_string(new, GIT_OID_HEXSZ+1, oid); git_oid_to_string(new, GIT_OID_HEXSZ+1, oid);
git_reference_free(r);
error = git_buf_join_n(&log_path, '/', 3, error = git_buf_join_n(&log_path, '/', 3,
ref->owner->path_repository, GIT_REFLOG_DIR, ref->name); ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
......
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