0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-16 10:31:07 +00:00

prevent crash on rrdcontext apis when rrdcontexts is not initialized ()

prevent crash
This commit is contained in:
Costa Tsaousis 2022-08-27 18:50:48 +03:00 committed by GitHub
parent 96e64963ef
commit 84b07e6e28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2377,6 +2377,11 @@ static inline int rrdcontext_to_json_callback(const char *id, void *value, void
}
int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, const char *context, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
if(!host->rrdctx) {
error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
return HTTP_RESP_NOT_FOUND;
}
RRDCONTEXT_ACQUIRED *rca = (RRDCONTEXT_ACQUIRED *)dictionary_get_and_acquire_item((DICTIONARY *)host->rrdctx, context);
if(!rca) return HTTP_RESP_NOT_FOUND;
@ -2412,6 +2417,11 @@ int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, R
}
int rrdcontexts_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
if(!host->rrdctx) {
error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
return HTTP_RESP_NOT_FOUND;
}
char node_uuid[UUID_STR_LEN] = "";
if(host->node_id)