FcValueSave on hashed static strings in FcPatternAddWithBinding.
Add another st_dev check in FcDirCacheOpen.
+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
cache_hashed = FcDirCacheHashName (cache_file, collisions++);
if (!cache_hashed)
+ {
+ FcStrFree ((FcChar8 *)cache_file);
return -1;
+ }
if (fd > 0)
close (fd);
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;
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;
}
if (!FcAtomicReplaceOrig(atomic))
goto bail5;
FcStrFree ((FcChar8 *)cache_hashed);
+ FcStrFree ((FcChar8 *)cache_file);
FcAtomicUnlock (atomic);
FcAtomicDestroy (atomic);
return FcTrue;
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:
case FcOpString:
v.type = FcTypeString;
v.u.s = FcStrStaticName(e->u.sval);
- v = FcValueSave (v);
break;
case FcOpMatrix:
v.type = FcTypeMatrix;
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))
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;