From 7b2de72f5483378dda5f9c6ec92424f94ab93085 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 21 Oct 2014 22:19:20 +1100 Subject: [PATCH] Cope with calling send_notify before any notify exists by returning no message --- src/generator.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/generator.c b/src/generator.c index fe1f9b17..f9791257 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1007,6 +1007,10 @@ static void send_notify(proxy_instance_t *proxi, int *sockd) mutex_lock(&proxi->notify_lock); ni = proxi->current_notify; + if (unlikely(!ni)) { + mutex_unlock(&proxi->notify_lock); + goto out_close; + } for (i = 0; i < ni->merkles; i++) json_array_append_new(merkle_arr, json_string(&ni->merklehash[i][0])); /* Use our own jobid instead of the server's one for easy lookup */ @@ -1022,6 +1026,7 @@ static void send_notify(proxy_instance_t *proxi, int *sockd) json_decref(json_msg); send_unix_msg(*sockd, msg); free(msg); +out_close: _Close(sockd); }