From 8198127b2525084bfe2378b83c185fa0da7f583b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 1 Jan 2013 20:20:31 -0600 Subject: [PATCH] Don't crash in FcPatternFormat() with NULL pattern --- src/fcformat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fcformat.c b/src/fcformat.c index a8a1ad1..59f8681 100644 --- a/src/fcformat.c +++ b/src/fcformat.c @@ -1193,15 +1193,19 @@ FcPatternFormat (FcPattern *pat, { FcStrBuf buf; FcChar8 buf_static[8192 - 1024]; + FcPattern *alloced = NULL; FcBool ret; if (!pat) - return NULL; + alloced = pat = FcPatternCreate (); FcStrBufInit (&buf, buf_static, sizeof (buf_static)); ret = FcPatternFormatToBuf (pat, format, &buf); + if (alloced) + FcPatternDestroy (alloced); + if (ret) return FcStrBufDone (&buf); else