summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
authorStjepan Rajko <stjepanr@axosoft.com>2015-10-26 15:33:00 -0700
committerStjepan Rajko <stjepanr@axosoft.com>2015-10-29 11:15:37 -0700
commit335c9e2f45b75e9fe8d8256e6ecfdb3d333fcbcc (patch)
treef51716a273db565f78aa8621c00a846214b8e5de /src/refdb_fs.c
parent821131fdaee74526d84aaf1c6ceddc2139c551df (diff)
downloadlibgit2-335c9e2f45b75e9fe8d8256e6ecfdb3d333fcbcc.tar.gz
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
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c2
1 files changed, 1 insertions, 1 deletions
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)