[FcStrBuf] better handle malloc failure

If buffer has failed allocation, return NULL when done.
This commit is contained in:
Behdad Esfahbod 2009-02-10 04:47:24 -05:00
parent ced38254b4
commit dccbbe83ef
1 changed files with 7 additions and 1 deletions

View File

@ -733,7 +733,10 @@ FcStrBufDone (FcStrBuf *buf)
{
FcChar8 *ret;
ret = malloc (buf->len + 1);
if (buf->failed)
ret = NULL;
else
ret = malloc (buf->len + 1);
if (ret)
{
FcMemAlloc (FC_MEM_STRING, buf->len + 1);
@ -752,6 +755,9 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c)
FcChar8 *new;
int size;
if (buf->failed)
return FcFalse;
if (buf->allocated)
{
size = buf->size * 2;