From 861bd066feea6d8a4edbe66798d05f088ebfe168 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 26 Jul 2016 03:31:56 +0000 Subject: [PATCH] Bugfix: Restore calloc despite blktxn_init; if we fail before completing parsing the transaction, we need to avoid uncleared pointers --- blkmaker_jansson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blkmaker_jansson.c b/blkmaker_jansson.c index 390b08a..097276c 100644 --- a/blkmaker_jansson.c +++ b/blkmaker_jansson.c @@ -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; }