From dccbbe83eff54097c55fdc560810cdc56b679a60 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Feb 2009 04:47:24 -0500 Subject: [PATCH] [FcStrBuf] better handle malloc failure If buffer has failed allocation, return NULL when done. --- src/fcstr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- 2.39.2