From 335c9e2f45b75e9fe8d8256e6ecfdb3d333fcbcc Mon Sep 17 00:00:00 2001 From: Stjepan Rajko Date: Mon, 26 Oct 2015 15:33:00 -0700 Subject: Prevent segfault when parsing a reflog with oid parse error Using calloc instead of malloc because the parse error will lead to an immediate free of committer (and its properties, which can segfault on free if undefined - test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error segfaulted before the fix). #3458 --- src/refdb_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 921f7862b..9f87b30d4 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -1463,7 +1463,7 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) entry = git__calloc(1, sizeof(git_reflog_entry)); GITERR_CHECK_ALLOC(entry); - entry->committer = git__malloc(sizeof(git_signature)); + entry->committer = git__calloc(1, sizeof(git_signature)); GITERR_CHECK_ALLOC(entry->committer); if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0) -- cgit v1.2.1