From e89d5e45a02de1e26eaa64619e177fbb03a30b12 Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Tue, 13 Oct 2026 23:28:18 +0000 Subject: [PATCH] fix crash in consul_health when an entry has no Checks array ngx_http_upsync_consul_health_parse_json() dereferenced the result of cJSON_GetObjectItem(server_next, "Checks") without a NULL check, so a health entry without a "Checks" array crashed the worker. Skip the health check loop in that case, keeping the server and still applying its tags. --- src/ngx_http_upsync_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ngx_http_upsync_module.c b/src/ngx_http_upsync_module.c index 4619022..690b47a 100644 --- a/src/ngx_http_upsync_module.c +++ b/src/ngx_http_upsync_module.c @@ -1695,7 +1695,8 @@ ngx_http_upsync_consul_health_parse_json(void *data) checks = cJSON_GetObjectItem(server_next, "Checks"); - for (check_next = checks->child; check_next != NULL; + for (check_next = (checks != NULL) ? checks->child : NULL; + check_next != NULL; check_next = check_next->next) { cJSON *check_status;