From b47d0e34caaef298edfb7bd09a72cfff21d231ff Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Tue, 21 Feb 2017 09:17:34 +0100 Subject: [PATCH] cJSON_ArrayForEach: Fix handling of NULL pointers --- cJSON.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.h b/cJSON.h index 647cc62..88c9130 100644 --- a/cJSON.h +++ b/cJSON.h @@ -176,7 +176,7 @@ extern double cJSON_SetNumberHelper(cJSON *object, double number); #define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) /* Macro for iterating over an array */ -#define cJSON_ArrayForEach(pos, head) for(pos = (head)->child; pos != NULL; pos = pos->next) +#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) #ifdef __cplusplus }