prevent null pointer dereference if a statsd chart is defined before the app is defined
Costa Tsaousis (ktsaou) committed
May 5, 2017 at 21:27 UTC
f344d7dc05207e144256400d41bf86f7c864f542
1 file changed
+3
-1
src/statsd.c
+3
-1
@@ -974,7 +974,7 @@ int statsd_readfile(const char *path, const char *filename) {
974
statsd.apps = app;
975
chart = NULL;
976
}
977
- else {
977
+ else if(app) {
978
// a new chart
979
chart = callocz(sizeof(STATSD_APP_CHART), 1);
980
chart->id = strdupz(s);
@@ -988,6 +988,8 @@ int statsd_readfile(const char *path, const char *filename) {
988
chart->next = app->charts;
989
app->charts = chart;
990
}
991
+ else
992
+ error("STATSD: ignoring line %zu ('%s') of file '%s/%s', [app] is not defined.", line, s, path, filename);
993
994
continue;
995
}