diff options
author | Vladimir Kobal <vlad@prokk.net> | 2022-05-27 15:32:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 16:32:56 +0300 |
commit | 93486ebcbd0c19106dec619f3abb834bc07eb8e1 (patch) | |
tree | 1274d235eb375947c3c90d027ba03977e7358450 /collectors | |
parent | ef7cbc0e21d9bf9afcce4a8cc977379ccf64420e (diff) |
Initialize a pointer and add a check for it (#13023)
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/statsd.plugin/statsd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/collectors/statsd.plugin/statsd.c b/collectors/statsd.plugin/statsd.c index 2c38ddbc2c..95f23a1126 100644 --- a/collectors/statsd.plugin/statsd.c +++ b/collectors/statsd.plugin/statsd.c @@ -1589,14 +1589,14 @@ static inline void statsd_readdir(const char *user_path, const char *stock_path, // extract chart type and chart id from metric name static inline void statsd_get_metric_type_and_id(STATSD_METRIC *m, char *type, char *id, char *context, const char *metrictype, size_t len) { - char *s; + char *s = NULL; snprintfz(type, len, "%s_%s", STATSD_CHART_PREFIX, m->name); if(sizeof(STATSD_CHART_PREFIX) + 2 < len) for(s = &type[sizeof(STATSD_CHART_PREFIX) + 2]; *s ;s++) if(unlikely(*s == '.' || *s == '_')) break; - if(*s == '.' || *s == '_') { + if(s && (*s == '.' || *s == '_')) { *s++ = '\0'; snprintfz(id, len, "%s_%s", s, metrictype); } |