wall_john 发表于 2005-4-30 14:39:18

最近发现fontconfig(firefly)中有个BUG

最近发现fontconfig中有个BUG导致打开KDE控制中心字体安装程序异常退出。

BUG在 fontconfig-2.2.3/src/fccfg.c中

void
FcConfigAppFontClear (FcConfig *config)
{
FcConfigSetFonts (config, 0, FcSetApplication);
}

void
FcConfigSetFonts (FcConfig *config,
FcFontSet *fonts,
FcSetName set)
{
if (config->fonts)
FcFontSetDestroy (config->fonts);
/*---------------------------------------------------------*/
/* Add by Firefly([email protected]) */
#define ST_ITALIC 0
#define ST_BOLD 1
#define ST_BOLD_ITALIC 2
FcBool scalable;
FcPattern *pat;
FcChar8 *family;
int slant, weight;
int f;

for (f = 0; f < fonts->nfont; f++) //BUG: FcConfigSetFonts (config, 0, FcSetApplication); 这里 fonts为0 空指针错误!
{

.......
};

解决方法:
void
FcConfigSetFonts (FcConfig *config,
FcFontSet *fonts,
FcSetName set)
{
if (config->fonts)
FcFontSetDestroy (config->fonts);
/*---------------------------------------------------------*/
/* Add by Firefly([email protected]) */
#define ST_ITALIC 0
#define ST_BOLD 1
#define ST_BOLD_ITALIC 2
FcBool scalable;
FcPattern *pat;
FcChar8 *family;
int slant, weight;
int f;

if (fonts == 0) { //在这里加fonts值的判断
config->fonts = fonts;
return;
}

for (f = 0; f < fonts->nfont; f++)
{

.......
};

ajinn 发表于 2005-4-30 16:21:02

看到指针偶先去晕一会儿
页: [1]
查看完整版本: 最近发现fontconfig(firefly)中有个BUG