diff --git a/cJSON.c b/cJSON.c index 13d5a02..b16abae 100644 --- a/cJSON.c +++ b/cJSON.c @@ -167,6 +167,11 @@ static const unsigned char *parse_number(cJSON *item, const unsigned char *num) double number = 0; unsigned char *endpointer = NULL; + if (num == NULL) + { + return NULL; + } + number = strtod((const char*)num, (char**)&endpointer); if ((num == endpointer) || (num == NULL)) { diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 378a3e3..ccc250a 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -277,7 +277,7 @@ static cJSON *cJSONUtils_PatchDetach(cJSON *object, const unsigned char *path) static int cJSONUtils_Compare(cJSON *a, cJSON *b) { - if ((a->type & 0xFF) != (b->type & 0xFF)) + if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) { /* mismatched type. */ return -1;