Fix use after free (#15825)
Stelios Fragkakis committed
Aug 17, 2023 at 23:59 UTC
1dc121a12d8d6a43f051d501e3f4edd1bbc588cf
2 files changed
+5
-1
database/rrdhost.c
+2
-1
@@ -509,7 +509,8 @@ int is_legacy = 1;
509
if(t != host) {
510
netdata_log_error("Host '%s': cannot add host with machine guid '%s' to index. It already exists as host '%s' with machine guid '%s'.",
511
rrdhost_hostname(host), host->machine_guid, rrdhost_hostname(t), t->machine_guid);
512
- rrdhost_free___while_having_rrd_wrlock(host, true);
512
+ if (!is_localhost)
513
+ rrdhost_free___while_having_rrd_wrlock(host, true);
514
rrd_unlock();
515
return NULL;
516
}
ml/ml.cc
+3
@@ -1726,6 +1726,9 @@ void ml_stop_threads()
1726
Cfg.detection_stop = true;
1727
Cfg.training_stop = true;
1728
1729
+ if (!Cfg.detection_thread)
1730
+ return;
1731
+
1732
netdata_thread_cancel(Cfg.detection_thread);
1733
netdata_thread_join(Cfg.detection_thread, NULL);
1734