From ae2aafe6028be658bd1de0fe2dd309799bf575f7 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 10 Apr 2006 15:46:34 +0000 Subject: Fix double free (spotted by Coverity, CID #1965). Check if pattern is not null before using it (Coverity defect #1883). Fix memory leak with hash collision (Coverity defect #1829). Fix memory leak when bail cases (Coverity defect #1828). Don't leak directory name (Coverity defect #1827). reviewed by: plam --- fc-match/fc-match.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'fc-match/fc-match.c') diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c index 2666620..fa45018 100644 --- a/fc-match/fc-match.c +++ b/fc-match/fc-match.c @@ -134,6 +134,9 @@ main (int argc, char **argv) else pat = FcPatternCreate (); + if (!pat) + return 1; + FcConfigSubstitute (0, pat, FcMatchPattern); FcDefaultSubstitute (pat); @@ -147,8 +150,7 @@ main (int argc, char **argv) if (match) FcFontSetAdd (fs, match); } - if (pat) - FcPatternDestroy (pat); + FcPatternDestroy (pat); if (fs) { -- cgit v1.2.3