]> git.wh0rd.org - fontconfig.git/commitdiff
Don't leak FcValues string loaded through fcxml.c (#17661)
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 22 Sep 2008 22:16:30 +0000 (18:16 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 14 Feb 2009 00:54:00 +0000 (16:54 -0800)
Patch from Caolan McNamara.

src/fcpat.c
src/fcxml.c

index f9b533cf3e7c92da7434022194a4040a2010935a..4bff65993d3c4e2d04ef5368a580079e77f6b489 100644 (file)
@@ -27,7 +27,7 @@
 #include <assert.h>
 
 static FcBool
-FcStrHashed (const FcChar8 *name);
+FcHashOwnsName(const FcChar8 *name);
 
 FcPattern *
 FcPatternCreate (void)
@@ -50,7 +50,7 @@ FcValueDestroy (FcValue v)
 {
     switch (v.type) {
     case FcTypeString:
-        if (!FcStrHashed (v.u.s))
+        if (!FcHashOwnsName(v.u.s))
             FcStrFree ((FcChar8 *) v.u.s);
        break;
     case FcTypeMatrix:
@@ -131,7 +131,7 @@ FcValueListDestroy (FcValueListPtr l)
     {
        switch (l->value.type) {
        case FcTypeString:
-            if (!FcStrHashed ((FcChar8 *)l->value.u.s))
+            if (!FcHashOwnsName((FcChar8 *)l->value.u.s))
                 FcStrFree ((FcChar8 *)l->value.u.s);
            break;
        case FcTypeMatrix:
@@ -1041,14 +1041,14 @@ static struct objectBucket {
 } *FcObjectBuckets[OBJECT_HASH_SIZE];
 
 static FcBool
-FcStrHashed (const FcChar8 *name)
+FcHashOwnsName (const FcChar8 *name)
 {
     FcChar32           hash = FcStringHash (name);
     struct objectBucket        **p;
     struct objectBucket        *b;
 
     for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
-       if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1)))
+       if (b->hash == hash && ((char *)name == (char *) (b + 1)))
             return FcTrue;
     return FcFalse;
 }
index efdb297022ddb156bb44b4f02fc6727b7b04e974..b679dd16d773322f27cb1dde7631bcf61dfeb35f 100644 (file)
@@ -1997,8 +1997,10 @@ FcParsePatelt (FcConfigParse *parse)
        if (!FcPatternAdd (pattern, name, value, FcTrue))
        {
            FcConfigMessage (parse, FcSevereError, "out of memory");
+            FcValueDestroy(value);
            break;
        }
+        FcValueDestroy(value);
     }
 
     FcVStackPushPattern (parse, pattern);