ensure: Don't accept empty printbuffers anymore

This commit is contained in:
Max Bruckner 2017-02-19 04:20:21 +01:00
parent 9bf531ca05
commit 3c4d309f62
1 changed files with 2 additions and 6 deletions

View File

@ -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)
{