Fix additional memory leaks reported by Ronny V. Vindenes: don't invoke
FcValueSave on hashed static strings in FcPatternAddWithBinding. Add another st_dev check in FcDirCacheOpen.
This commit is contained in:
parent
16a71eff3e
commit
575a37b797
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-01-25 Patrick Lam <plam@mit.edu>
|
||||
* src/fccache.c (FcDirCacheOpen, FcDirCacheWrite):
|
||||
* src/fccfg.c (FcConfigEvaluate):
|
||||
* src/fcfreetype.c (FcPatternAddWithBinding):
|
||||
|
||||
Fix additional memory leaks reported by Ronny V. Vindenes: don't
|
||||
invoke FcValueSave on hashed static strings in
|
||||
FcPatternAddWithBinding.
|
||||
|
||||
Add another st_dev check in FcDirCacheOpen.
|
||||
|
||||
2006-01-24 James Su <james.su@gmail.com>
|
||||
reviewed by: plam
|
||||
|
||||
|
|
|
@ -900,7 +900,10 @@ FcDirCacheOpen (const FcChar8 *dir)
|
|||
|
||||
cache_hashed = FcDirCacheHashName (cache_file, collisions++);
|
||||
if (!cache_hashed)
|
||||
{
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd > 0)
|
||||
close (fd);
|
||||
|
@ -908,7 +911,10 @@ FcDirCacheOpen (const FcChar8 *dir)
|
|||
FcStrFree ((FcChar8 *)cache_hashed);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
return -1;
|
||||
}
|
||||
FcCacheReadString (fd, name_buf, sizeof (name_buf));
|
||||
if (!strlen(name_buf))
|
||||
goto bail;
|
||||
|
@ -920,11 +926,13 @@ FcDirCacheOpen (const FcChar8 *dir)
|
|||
continue;
|
||||
}
|
||||
FcStrFree (name_buf_dir);
|
||||
found = c.st_ino == dir_stat.st_ino;
|
||||
found = (c.st_ino == dir_stat.st_ino) && (c.st_dev == dir_stat.st_dev);
|
||||
} while (!found);
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
return fd;
|
||||
|
||||
bail:
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1200,6 +1208,7 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
|
|||
if (!FcAtomicReplaceOrig(atomic))
|
||||
goto bail5;
|
||||
FcStrFree ((FcChar8 *)cache_hashed);
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
FcAtomicUnlock (atomic);
|
||||
FcAtomicDestroy (atomic);
|
||||
return FcTrue;
|
||||
|
@ -1216,7 +1225,7 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
|
|||
FcStrFree ((FcChar8 *)cache_hashed);
|
||||
bail0:
|
||||
unlink ((char *)cache_file);
|
||||
free (cache_file);
|
||||
FcStrFree ((FcChar8 *)cache_file);
|
||||
if (current_dir_block)
|
||||
free (current_dir_block);
|
||||
bail:
|
||||
|
|
|
@ -827,7 +827,6 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
|
|||
case FcOpString:
|
||||
v.type = FcTypeString;
|
||||
v.u.s = FcStrStaticName(e->u.sval);
|
||||
v = FcValueSave (v);
|
||||
break;
|
||||
case FcOpMatrix:
|
||||
v.type = FcTypeMatrix;
|
||||
|
@ -847,7 +846,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
|
|||
r = FcPatternGet (p, e->u.field, 0, &v);
|
||||
if (r != FcResultMatch)
|
||||
v.type = FcTypeVoid;
|
||||
v = FcValueSave (v);
|
||||
v = FcValueSave (v);
|
||||
break;
|
||||
case FcOpConst:
|
||||
if (FcNameConstant (e->u.constant, &v.u.i))
|
||||
|
|
|
@ -874,7 +874,14 @@ FcPatternAddWithBinding (FcPattern *p,
|
|||
new = FcValueListPtrCreateDynamic(newp);
|
||||
FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
|
||||
/* dup string */
|
||||
value = FcValueSave (value);
|
||||
if (value.type == FcTypeString)
|
||||
{
|
||||
value.u.s = FcStrStaticName (value.u.s);
|
||||
if (!value.u.s)
|
||||
value.type = FcTypeVoid;
|
||||
}
|
||||
else
|
||||
value = FcValueSave (value);
|
||||
if (value.type == FcTypeVoid)
|
||||
goto bail1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue