@cryptotaxi247 / netdata-1 / commits / 5ce7b4afe

Fixed invalid pointer access `rrddim_free_custom` (#9326)

Fixed invalid memory access in host creation and dimension deletion

Stelios Fragkakis committed Jun 12, 2020 at 15:40 UTC 5ce7b4afe4c3a61f4c47e7c4926554dca433979c
2 files changed +3 -2
database/rrddim.c
+2 -1
@@ -494,6 +494,7 @@ void rrddim_free_custom(RRDSET *st, RRDDIM *rd, int db_rotated)
494
495 // free(rd->annotations);
496
497 + RRD_MEMORY_MODE rrd_memory_mode = rd->rrd_memory_mode;
498 switch(rd->rrd_memory_mode) {
499 case RRD_MEMORY_MODE_SAVE:
500 case RRD_MEMORY_MODE_MAP:
@@ -514,7 +515,7 @@ void rrddim_free_custom(RRDSET *st, RRDDIM *rd, int db_rotated)
515 break;
516 }
517 #ifdef ENABLE_ACLK
517 - if ((netdata_cloud_setting) && (db_rotated || RRD_MEMORY_MODE_DBENGINE != rd->rrd_memory_mode))
518 + if ((netdata_cloud_setting) && (db_rotated || RRD_MEMORY_MODE_DBENGINE != rrd_memory_mode))
519 aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
520 #endif
521 #ifdef ENABLE_DBENGINE
database/rrdhost.c
+1 -1
@@ -365,7 +365,7 @@ RRDHOST *rrdhost_create(const char *hostname,
365 rrd_hosts_available++;
366
367 #ifdef ENABLE_DBENGINE
368 - if (likely(!is_localhost && host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE))
368 + if (likely(!is_localhost && host && host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE))
369 metalog_commit_update_host(host);
370 #endif
371 return host;