summaryrefslogtreecommitdiff
path: root/src/fcname.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2012-03-28 13:37:15 +0900
committerAkira TAGOH <akira@tagoh.org>2012-03-28 13:42:01 +0900
commitd8dcff7b96b09748e6f1df9e4adc7ab0850d7b18 (patch)
tree9f51c5a07e32e988333a84eb97d2425cbba10b60 /src/fcname.c
parentea1c6ea337b8cf6b86169b565787d0d31a0fc330 (diff)
downloadfontconfig-d8dcff7b96b09748e6f1df9e4adc7ab0850d7b18.tar.gz
Bug 17832 - Memory leaks due to FcStrStaticName use for external patterns
Use the reference-counted strings instead of the static strings Patch from Karl Tomlinson
Diffstat (limited to 'src/fcname.c')
-rw-r--r--src/fcname.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/fcname.c b/src/fcname.c
index 1b32b0f..d0b1ca8 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -572,9 +572,10 @@ FcNameBool (const FcChar8 *v, FcBool *result)
}
static FcValue
-FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
+FcNameConvert (FcType type, FcChar8 *string)
{
FcValue v;
+ FcMatrix m;
v.type = type;
switch (v.type) {
@@ -583,7 +584,7 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
v.u.i = atoi ((char *) string);
break;
case FcTypeString:
- v.u.s = FcStrStaticName(string);
+ v.u.s = FcSharedStr (string);
if (!v.u.s)
v.type = FcTypeVoid;
break;
@@ -595,8 +596,8 @@ FcNameConvert (FcType type, FcChar8 *string, FcMatrix *m)
v.u.d = strtod ((char *) string, 0);
break;
case FcTypeMatrix:
- v.u.m = m;
- sscanf ((char *) string, "%lg %lg %lg %lg", &m->xx, &m->xy, &m->yx, &m->yy);
+ sscanf ((char *) string, "%lg %lg %lg %lg", &m.xx, &m.xy, &m.yx, &m.yy);
+ v.u.m = FcMatrixCopy (&m);
break;
case FcTypeCharSet:
v.u.c = FcNameParseCharSet (string);
@@ -648,7 +649,6 @@ FcNameParse (const FcChar8 *name)
FcChar8 *e;
FcChar8 delim;
FcValue v;
- FcMatrix m;
const FcObjectType *t;
const FcConstant *c;
@@ -699,31 +699,13 @@ FcNameParse (const FcChar8 *name)
name = FcNameFindNext (name, ":,", save, &delim);
if (t)
{
- v = FcNameConvert (t->type, save, &m);
+ v = FcNameConvert (t->type, save);
if (!FcPatternAdd (pat, t->object, v, FcTrue))
{
- switch (v.type) {
- case FcTypeCharSet:
- FcCharSetDestroy ((FcCharSet *) v.u.c);
- break;
- case FcTypeLangSet:
- FcLangSetDestroy ((FcLangSet *) v.u.l);
- break;
- default:
- break;
- }
+ FcValueDestroy (v);
goto bail2;
}
- switch (v.type) {
- case FcTypeCharSet:
- FcCharSetDestroy ((FcCharSet *) v.u.c);
- break;
- case FcTypeLangSet:
- FcLangSetDestroy ((FcLangSet *) v.u.l);
- break;
- default:
- break;
- }
+ FcValueDestroy (v);
}
if (delim != ',')
break;