From: Behdad Esfahbod Date: Tue, 10 Feb 2009 09:47:24 +0000 (-0500) Subject: [FcStrBuf] better handle malloc failure X-Git-Tag: 2.7.0~92 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=dccbbe83eff54097c55fdc560810cdc56b679a60;p=fontconfig.git [FcStrBuf] better handle malloc failure If buffer has failed allocation, return NULL when done. --- diff --git a/src/fcstr.c b/src/fcstr.c index 2f2cd4d..3b84ac0 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -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;