Fix CFI builds
CFI [1] is a dynamic analysis tool that checks types at runtime. It reports an error when using a function with signature eg. (void (*)(char*)) as (void (*)(void*)). This change adds some wrapper functions to avoid this issue. In optimized builds, the functions should get optimized away. [1] https://clang.llvm.org/docs/ControlFlowIntegrity.html
This commit is contained in:
parent
d1771cfbd1
commit
096e8019be
42
src/fccfg.c
42
src/fccfg.c
|
@ -52,6 +52,36 @@ retry:
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FcChar32
|
||||||
|
FcHashAsStrIgnoreCase (const void *data)
|
||||||
|
{
|
||||||
|
return FcStrHashIgnoreCase (data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
FcCompareAsStr (const void *v1, const void *v2)
|
||||||
|
{
|
||||||
|
return FcStrCmp (v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FcDestroyAsRule (void *data)
|
||||||
|
{
|
||||||
|
FcRuleDestroy (data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FcDestroyAsRuleSet (void *data)
|
||||||
|
{
|
||||||
|
FcRuleSetDestroy (data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FcDestroyAsStr (void *data)
|
||||||
|
{
|
||||||
|
FcStrFree (data);
|
||||||
|
}
|
||||||
|
|
||||||
FcBool
|
FcBool
|
||||||
FcConfigInit (void)
|
FcConfigInit (void)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +143,7 @@ FcConfigCreate (void)
|
||||||
|
|
||||||
for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++)
|
for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++)
|
||||||
{
|
{
|
||||||
config->subst[k] = FcPtrListCreate ((FcDestroyFunc) FcRuleSetDestroy);
|
config->subst[k] = FcPtrListCreate (FcDestroyAsRuleSet);
|
||||||
if (!config->subst[k])
|
if (!config->subst[k])
|
||||||
err = FcTrue;
|
err = FcTrue;
|
||||||
}
|
}
|
||||||
|
@ -131,18 +161,18 @@ FcConfigCreate (void)
|
||||||
|
|
||||||
config->sysRoot = NULL;
|
config->sysRoot = NULL;
|
||||||
|
|
||||||
config->rulesetList = FcPtrListCreate ((FcDestroyFunc) FcRuleSetDestroy);
|
config->rulesetList = FcPtrListCreate (FcDestroyAsRuleSet);
|
||||||
if (!config->rulesetList)
|
if (!config->rulesetList)
|
||||||
goto bail9;
|
goto bail9;
|
||||||
config->availConfigFiles = FcStrSetCreate ();
|
config->availConfigFiles = FcStrSetCreate ();
|
||||||
if (!config->availConfigFiles)
|
if (!config->availConfigFiles)
|
||||||
goto bail10;
|
goto bail10;
|
||||||
|
|
||||||
config->uuid_table = FcHashTableCreate ((FcHashFunc) FcStrHashIgnoreCase,
|
config->uuid_table = FcHashTableCreate (FcHashAsStrIgnoreCase,
|
||||||
(FcCompareFunc) FcStrCmp,
|
FcCompareAsStr,
|
||||||
FcHashStrCopy,
|
FcHashStrCopy,
|
||||||
FcHashUuidCopy,
|
FcHashUuidCopy,
|
||||||
(FcDestroyFunc) FcStrFree,
|
FcDestroyAsStr,
|
||||||
FcHashUuidFree);
|
FcHashUuidFree);
|
||||||
|
|
||||||
FcRefInit (&config->ref, 1);
|
FcRefInit (&config->ref, 1);
|
||||||
|
@ -2491,7 +2521,7 @@ FcRuleSetCreate (const FcChar8 *name)
|
||||||
ret->description = NULL;
|
ret->description = NULL;
|
||||||
ret->domain = NULL;
|
ret->domain = NULL;
|
||||||
for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++)
|
for (k = FcMatchKindBegin; k < FcMatchKindEnd; k++)
|
||||||
ret->subst[k] = FcPtrListCreate ((FcDestroyFunc) FcRuleDestroy);
|
ret->subst[k] = FcPtrListCreate (FcDestroyAsRule);
|
||||||
FcRefInit (&ret->ref, 1);
|
FcRefInit (&ret->ref, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue