mirror of
https://github.com/DaveGamble/cJSON
synced 2024-12-24 23:52:07 +00:00
fix potential NULL dereferences found by coverity
This commit is contained in:
parent
49b9336558
commit
4047de4f6e
5
cJSON.c
5
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))
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user