From 7cf768fddfe03a139f269594cbbe8b18b61db0fd Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 25 Apr 2014 20:29:35 +1000 Subject: [PATCH] Cope with the unlikely event we have been requested a mining subscribe before any work templates have been generated --- src/stratifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 60c33f5d..02c8569f 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -445,6 +445,7 @@ static json_t *parse_subscribe(int client_id, json_t *params_val) char *enonce1; int arr_size; json_t *ret; + int n2len; if (unlikely(!json_is_array(params_val))) return json_string("params not an array"); @@ -474,7 +475,11 @@ static json_t *parse_subscribe(int client_id, json_t *params_val) ck_runlock(&instance_lock); ck_rlock(&workbase_lock); - ret = json_pack("[[s,s],s,i]", "mining.notify", enonce1, enonce1, workbases->enonce2varlen); + if (likely(workbases)) + n2len = workbases->enonce2varlen; + else + n2len = 8; + ret = json_pack("[[s,s],s,i]", "mining.notify", enonce1, enonce1, n2len); ck_runlock(&workbase_lock); free(enonce1);