mirror of
https://github.com/DaveGamble/cJSON.git
synced 2024-12-27 14:14:07 +08: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;
|
double number = 0;
|
||||||
unsigned char *endpointer = NULL;
|
unsigned char *endpointer = NULL;
|
||||||
|
|
||||||
|
if (num == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
number = strtod((const char*)num, (char**)&endpointer);
|
number = strtod((const char*)num, (char**)&endpointer);
|
||||||
if ((num == endpointer) || (num == NULL))
|
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)
|
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. */
|
/* mismatched type. */
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user