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