Ok, second day of Coverity fixes. First patch fixes three memleaks in fcpat.c (Coverity defect #1820, #1821, #1822) when malloc fails. -- Frederic Crozat <fcrozat@xxxxxxxxxxxx> Mandriva
Index: ChangeLog =================================================================== RCS file: /cvs/fontconfig/fontconfig/ChangeLog,v retrieving revision 1.109.2.192 diff -u -p -r1.109.2.192 ChangeLog --- ChangeLog 11 Apr 2006 05:08:26 -0000 1.109.2.192 +++ ChangeLog 11 Apr 2006 11:50:52 -0000 @@ -1,3 +1,9 @@ +2006-04-11 Frederic Crozat <fcrozat@xxxxxxxxxxxx> + + * src/fcpat.c: (FcValueListEntCreate), (FcPatternBaseFreeze), + (FcPatternFreeze): + Fix memory leak in error case (Coverity defects #1820, #1821, #1822). + 2006-04-11 Behdad Esfahbod <behdad@xxxxxxxxxxxxxx> reviewed by: plam Index: src/fcpat.c =================================================================== RCS file: /cvs/fontconfig/fontconfig/src/fcpat.c,v retrieving revision 1.27.2.39 diff -u -p -r1.27.2.39 fcpat.c --- src/fcpat.c 7 Apr 2006 17:27:39 -0000 1.27.2.39 +++ src/fcpat.c 11 Apr 2006 11:50:52 -0000 @@ -398,8 +398,10 @@ FcValueListEntCreate (FcValueListPtr h) if (!ea) return 0; new = malloc (n * sizeof (FcValueList)); - if (!new) + if (!new) { + free (ea); return 0; + } memset(new, 0, n * sizeof (FcValueList)); FcMemAlloc (FC_MEM_VALLIST, size); e = &ea->ent; @@ -575,11 +577,13 @@ FcPatternBaseFreeze (FcPattern *b) ep = FcPatternCreate(); if (!ep) - return 0; + goto bail; ent->pattern = ep; epp = malloc(b->num * sizeof (FcPatternElt)); - if (!epp) + if (!epp) { + FcPatternDestroy (ep); goto bail; + } ep->elts = FcPatternEltPtrCreateDynamic(epp); FcMemAlloc (FC_MEM_PATELT, sizeof (FcPatternElt)*(b->num)); @@ -649,8 +653,10 @@ FcPatternFreeze (FcPattern *p) b->ref = 1; e = malloc(b->num * sizeof (FcPatternElt)); - if (!e) + if (!e) { + FcPatternDestroy (b); return 0; + } b->elts = FcPatternEltPtrCreateDynamic(e); FcMemAlloc (FC_MEM_PATELT, sizeof (FcPatternElt)*(b->num));
_______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig