Bugfix: Restore calloc despite blktxn_init; if we fail before completing parsing the transaction, we need to avoid uncleared pointers

This commit is contained in:
Luke Dashjr
2016-07-26 03:31:56 +00:00
parent 56187b6710
commit 861bd066fe

View File

@@ -281,7 +281,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;
for (size_t i = 0; i < txns; ++i)
{
@@ -294,7 +294,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;
}