mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
ensure: Don't accept empty printbuffers anymore
This commit is contained in:
parent
9bf531ca05
commit
3c4d309f62
8
cJSON.c
8
cJSON.c
@ -241,9 +241,9 @@ static unsigned char* ensure(printbuffer *p, size_t needed)
|
|||||||
unsigned char *newbuffer = NULL;
|
unsigned char *newbuffer = NULL;
|
||||||
size_t newsize = 0;
|
size_t newsize = 0;
|
||||||
|
|
||||||
if (p == NULL)
|
if ((p == NULL) || (p->buffer == NULL))
|
||||||
{
|
{
|
||||||
return (unsigned char*)cJSON_malloc(needed);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needed > INT_MAX)
|
if (needed > INT_MAX)
|
||||||
@ -252,10 +252,6 @@ static unsigned char* ensure(printbuffer *p, size_t needed)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->buffer == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
needed += p->offset;
|
needed += p->offset;
|
||||||
if (needed <= p->length)
|
if (needed <= p->length)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user