diff --git a/blkmaker_jansson.c b/blkmaker_jansson.c index cad51be..1d29c2d 100644 --- a/blkmaker_jansson.c +++ b/blkmaker_jansson.c @@ -305,7 +305,7 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t v = json_object_get(json, "transactions"); size_t txns = tmpl->txncount = json_array_size(v); - tmpl->txns = malloc(txns * sizeof(*tmpl->txns)); + tmpl->txns = calloc(txns, sizeof(*tmpl->txns)); tmpl->txns_datasz = 0; tmpl->txns_sigops = 0; for (size_t i = 0; i < txns; ++i) @@ -327,7 +327,7 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t if ((v = json_object_get(json, "coinbasetxn")) && json_is_object(v)) { - tmpl->cbtxn = malloc(sizeof(*tmpl->cbtxn)); + tmpl->cbtxn = calloc(1, sizeof(*tmpl->cbtxn)); if ((s = parse_txn(tmpl->cbtxn, v, 0))) return s; }