From b2dda538c8d0fc0328c6082ad71960604cbe3bd8 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 17 Feb 2018 17:45:24 +0000 Subject: [PATCH] blkmk_init_generation*: Correct output newcb value even in error conditions --- blkmaker.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blkmaker.c b/blkmaker.c index 63e32b8..4790814 100644 --- a/blkmaker.c +++ b/blkmaker.c @@ -56,20 +56,19 @@ bool _blkmk_dblsha256(void *hash, const void *data, size_t datasz) { #define dblsha256 _blkmk_dblsha256 uint64_t blkmk_init_generation3(blktemplate_t * const tmpl, const void * const script, const size_t scriptsz, bool * const inout_newcb) { - if (tmpl->cbtxn && !(*inout_newcb && (tmpl->mutations & BMM_GENERATE))) + const bool replace_existing = *inout_newcb; + *inout_newcb = false; + + if (tmpl->cbtxn && !(replace_existing && (tmpl->mutations & BMM_GENERATE))) { - *inout_newcb = false; return 0; } if (!tmpl->cbvalue) { // TODO: Figure it out from the existing cbtxn - *inout_newcb = false; return 0; } - *inout_newcb = true; - if (scriptsz >= 0xfd) return 0; @@ -133,6 +132,7 @@ uint64_t blkmk_init_generation3(blktemplate_t * const tmpl, const void * const s tmpl->mutations |= BMM_CBAPPEND | BMM_CBSET | BMM_GENERATE; + *inout_newcb = true; return tmpl->cbvalue; }