From 3ea92166a0e45b0c7d7e9ecc0546317640c50336 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 10 Apr 2006 19:33:03 +0000 Subject: [PATCH] Fix string memory leak (Coverity defect #1823). Fix memory leak with hash collision (Coverity defect #1824). reviewed by: plam --- ChangeLog | 9 +++++++++ src/fccache.c | 1 + src/fccfg.c | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c1185f6..b35be7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-04-10 Frederic Crozat + reviewed by: plam + + * src/fccfg.c: (FcConfigEvaluate): + Fix string memory leak (Coverity defect #1823). + + * src/fccache.c: (FcDirCacheUnlink): + Fix memory leak with hash collision (Coverity defect #1824). + 2006-04-10 Frederic Crozat reviewed by: plam diff --git a/src/fccache.c b/src/fccache.c index 042439e..23c37f1 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -854,6 +854,7 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config) fd = open(cache_hashed, O_RDONLY | O_BINARY); if (fd == -1) { + FcStrFree ((FcChar8 *)cache_hashed); FcStrFree ((FcChar8 *)cache_file); return FcTrue; } diff --git a/src/fccfg.c b/src/fccfg.c index 7f8a8ff..fc70fef 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -893,6 +893,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e) FcValue v, vl, vr; FcResult r; FcMatrix *m; + FcChar8 *str; switch (e->op) { case FcOpInteger: @@ -1023,7 +1024,9 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e) switch (e->op) { case FcOpPlus: v.type = FcTypeString; - v.u.s = FcStrStaticName (FcStrPlus (vl.u.s, vr.u.s)); + str = FcStrPlus (vl.u.s, vr.u.s); + v.u.s = FcStrStaticName (str); + FcStrFree (str); if (!v.u.s) v.type = FcTypeVoid; -- 2.39.5