mirror of
https://github.com/DaveGamble/cJSON.git
synced 2024-12-26 12:41:03 +08: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;
|
||||
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)
|
||||
@ -252,10 +252,6 @@ static unsigned char* ensure(printbuffer *p, size_t needed)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (p->buffer == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
needed += p->offset;
|
||||
if (needed <= p->length)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user