From 3e1d5eb977be0f56dfe32f5d746ded1ad6213346 Mon Sep 17 00:00:00 2001 From: Andrew Moss <1043609+amoss@users.noreply.github.com> Date: Mon, 8 Jun 2020 23:43:56 +0200 Subject: Fix crash in #9291 (#9297) Did not account for the path where rrdhost_find_or_create fails and terminates the thread before setting rpt->host to a valid pointer. --- streaming/receiver.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'streaming') diff --git a/streaming/receiver.c b/streaming/receiver.c index 39a606e291..380d49137c 100644 --- a/streaming/receiver.c +++ b/streaming/receiver.c @@ -11,10 +11,12 @@ static void rrdpush_receiver_thread_cleanup(void *ptr) { struct receiver_state *rpt = (struct receiver_state *) ptr; // Make sure that we detach this thread and don't kill a freshly arriving receiver - netdata_mutex_lock(&rpt->host->receiver_lock); - if (rpt->host->receiver == rpt) - rpt->host->receiver = NULL; - netdata_mutex_unlock(&rpt->host->receiver_lock); + if (rpt->host) { + netdata_mutex_lock(&rpt->host->receiver_lock); + if (rpt->host->receiver == rpt) + rpt->host->receiver = NULL; + netdata_mutex_unlock(&rpt->host->receiver_lock); + } info("STREAM %s [receive from [%s]:%s]: receive thread ended (task id %d)", rpt->hostname, rpt->client_ip, rpt->client_port, gettid()); -- cgit v1.2.3