Commit 4a782c82 by Russell Belfer

Merge pull request #1574 from linquize/calloc

Use calloc() for safety
parents 12f831fa 7026ad89
...@@ -259,7 +259,7 @@ static int store_object(git_indexer_stream *idx) ...@@ -259,7 +259,7 @@ static int store_object(git_indexer_stream *idx)
entry = git__calloc(1, sizeof(*entry)); entry = git__calloc(1, sizeof(*entry));
GITERR_CHECK_ALLOC(entry); GITERR_CHECK_ALLOC(entry);
pentry = git__malloc(sizeof(struct git_pack_entry)); pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry); GITERR_CHECK_ALLOC(pentry);
git_hash_final(&oid, ctx); git_hash_final(&oid, ctx);
...@@ -328,7 +328,7 @@ static int hash_and_save(git_indexer_stream *idx, git_rawobj *obj, git_off_t ent ...@@ -328,7 +328,7 @@ static int hash_and_save(git_indexer_stream *idx, git_rawobj *obj, git_off_t ent
return -1; return -1;
} }
pentry = git__malloc(sizeof(struct git_pack_entry)); pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry); GITERR_CHECK_ALLOC(pentry);
git_oid_cpy(&pentry->sha1, &oid); git_oid_cpy(&pentry->sha1, &oid);
......
...@@ -576,7 +576,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt) ...@@ -576,7 +576,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
switch (pkt->type) { switch (pkt->type) {
case GIT_PKT_OK: case GIT_PKT_OK:
status = git__malloc(sizeof(push_status)); status = git__calloc(1, sizeof(push_status));
GITERR_CHECK_ALLOC(status); GITERR_CHECK_ALLOC(status);
status->msg = NULL; status->msg = NULL;
status->ref = git__strdup(((git_pkt_ok *)pkt)->ref); status->ref = git__strdup(((git_pkt_ok *)pkt)->ref);
......
...@@ -32,7 +32,7 @@ git__DIR *git__opendir(const char *dir) ...@@ -32,7 +32,7 @@ git__DIR *git__opendir(const char *dir)
if (!dir || !init_filter(filter, sizeof(filter), dir)) if (!dir || !init_filter(filter, sizeof(filter), dir))
return NULL; return NULL;
new = git__malloc(sizeof(*new)); new = git__calloc(1, sizeof(*new));
if (!new) if (!new)
return NULL; return NULL;
......
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