@cryptotaxi247 / netdata-1 / commits / 93486ebcb

Initialize a pointer and add a check for it (#13023)

Vladimir Kobal committed May 27, 2022 at 15:32 UTC 93486ebcbd0c19106dec619f3abb834bc07eb8e1
1 file changed +2 -2
collectors/statsd.plugin/statsd.c
+2 -2
@@ -1589,14 +1589,14 @@ static inline void statsd_readdir(const char *user_path, const char *stock_path,
1589
1590 // extract chart type and chart id from metric name
1591 static inline void statsd_get_metric_type_and_id(STATSD_METRIC *m, char *type, char *id, char *context, const char *metrictype, size_t len) {
1592 - char *s;
1592 + char *s = NULL;
1593
1594 snprintfz(type, len, "%s_%s", STATSD_CHART_PREFIX, m->name);
1595 if(sizeof(STATSD_CHART_PREFIX) + 2 < len)
1596 for(s = &type[sizeof(STATSD_CHART_PREFIX) + 2]; *s ;s++)
1597 if(unlikely(*s == '.' || *s == '_')) break;
1598
1599 - if(*s == '.' || *s == '_') {
1599 + if(s && (*s == '.' || *s == '_')) {
1600 *s++ = '\0';
1601 snprintfz(id, len, "%s_%s", s, metrictype);
1602 }