commit 45ab1a406e795a17f73efe6df198de6f978e15db
parent 1d56642a3adb78558e7f94432b3203f7a9225139
Author: Chris Bracken <chris@bracken.jp>
Date: Tue, 17 Feb 2026 17:49:49 +0900
commit: make author_name an owned copy
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/git/commit.c b/src/git/commit.c
@@ -20,7 +20,7 @@ struct GitCommit {
char* message;
time_t commit_time;
int commit_timezone_offset;
- const char* author_name;
+ char* author_name;
const char* author_email;
time_t author_time;
int author_timezone_offset;
@@ -60,7 +60,7 @@ GitCommit* gitcommit_create(const git_oid* oid, git_repository* repo) {
// Get author info.
const git_signature* author = git_commit_author(commit->commit);
- commit->author_name = author->name;
+ commit->author_name = author->name ? estrdup(author->name) : NULL;
commit->author_email = author->email;
commit->author_time = author->when.time;
commit->author_timezone_offset = author->when.offset;
@@ -142,6 +142,7 @@ void gitcommit_free(GitCommit* commit) {
free(commit->parentoid);
free(commit->summary);
free(commit->message);
+ free(commit->author_name);
for (size_t i = 0; i < commit->deltas_len; i++) {
gitdelta_free(commit->deltas[i]);
commit->deltas[i] = NULL;