cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit 4047de4f6e0c86db54a45c624543d43100340dbb
parent 49b9336558521209c6c4adf3ea3dc880a9ac206d
Author: Max Bruckner <max@maxbruckner.de>
Date:   Wed,  8 Feb 2017 03:00:44 +0100

fix potential NULL dereferences found by coverity

Diffstat:
McJSON.c | 5+++++
McJSON_Utils.c | 2+-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 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 @@ -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;