@cryptotaxi247 / netdata-1 / commits / 07af3ccbc

prevent passing unitialized memory to pthreads init functions; contributes to #1419

Costa Tsaousis (ktsaou) committed Dec 21, 2016 at 20:50 UTC 07af3ccbc391d3d25db05dfc44815a1150b845c3
1 file changed +6
src/rrd.c
+6
@@ -548,6 +548,11 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
548 st->mapped = rrd_memory_mode;
549 st->variables = NULL;
550 st->alarms = NULL;
551 + memset(&st->rwlock, 0, sizeof(pthread_rwlock_t));
552 + memset(&st->avl, 0, sizeof(avl));
553 + memset(&st->avlname, 0, sizeof(avl));
554 + memset(&st->variables_root_index, 0, sizeof(avl_tree_lock));
555 + memset(&st->dimensions_index, 0, sizeof(avl_tree_lock));
556 }
557 else {
558 st = callocz(1, size);
@@ -708,6 +713,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
713 rd->variables = NULL;
714 rd->next = NULL;
715 rd->name = NULL;
716 + memset(&rd->avl, 0, sizeof(avl));
717 }
718 else {
719 // if we didn't manage to get a mmap'd dimension, just create one