@cryptotaxi247 / netdata-1 / commits / 3e1d5eb97

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.

Andrew Moss committed Jun 8, 2020 at 23:43 UTC 3e1d5eb977be0f56dfe32f5d746ded1ad6213346
1 file changed +6 -4
streaming/receiver.c
+6 -4
@@ -11,10 +11,12 @@ static void rrdpush_receiver_thread_cleanup(void *ptr) {
11 struct receiver_state *rpt = (struct receiver_state *) ptr;
12
13 // Make sure that we detach this thread and don't kill a freshly arriving receiver
14 - netdata_mutex_lock(&rpt->host->receiver_lock);
15 - if (rpt->host->receiver == rpt)
16 - rpt->host->receiver = NULL;
17 - netdata_mutex_unlock(&rpt->host->receiver_lock);
14 + if (rpt->host) {
15 + netdata_mutex_lock(&rpt->host->receiver_lock);
16 + if (rpt->host->receiver == rpt)
17 + rpt->host->receiver = NULL;
18 + netdata_mutex_unlock(&rpt->host->receiver_lock);
19 + }
20
21 info("STREAM %s [receive from [%s]:%s]: receive thread ended (task id %d)", rpt->hostname, rpt->client_ip, rpt->client_port, gettid());
22