Fix possible crash in FontConfig database
In the FontConfig font database, when we registered alternative names for the same font, we would just copy the existing user data (the FontFile struct) from the original font. However, this did not account for the fact that registerFont() may in some cases delete fonts from the database if they are being overwritten, which will also delete the user data. Therefore the existing FontFile struct is not guaranteed to be valid once the font database has taken ownership. This was pre-existing, but it started happening on some systems after 1d6f71779f05df1af3daacd48f309cd92523152a because this change will cause some fonts to be seen as identical which were not before. Pick-to: 6.8 6.9 Fixes: QTBUG-135264 Change-Id: I913bf13dc8069d952a4cdc5fa5544594be1cdba1 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
0ca934b923
commit
11620f97f6
@ -465,9 +465,7 @@ static void populateFromPattern(FcPattern *pattern,
|
|||||||
writingSystems.setSupported(QFontDatabase::Other);
|
writingSystems.setSupported(QFontDatabase::Other);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontFile *fontFile = new FontFile;
|
QString fileName = QString::fromLocal8Bit((const char *)file_value);
|
||||||
fontFile->fileName = QString::fromLocal8Bit((const char *)file_value);
|
|
||||||
fontFile->indexValue = indexValue;
|
|
||||||
|
|
||||||
QFont::Style style = (slant_value == FC_SLANT_ITALIC)
|
QFont::Style style = (slant_value == FC_SLANT_ITALIC)
|
||||||
? QFont::StyleItalic
|
? QFont::StyleItalic
|
||||||
@ -503,7 +501,24 @@ static void populateFromPattern(FcPattern *pattern,
|
|||||||
applicationFont->properties.append(properties);
|
applicationFont->properties.append(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformFontDatabase::registerFont(familyName,styleName,QLatin1StringView((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,fixedPitch,colorFont,writingSystems,fontFile);
|
{
|
||||||
|
FontFile *fontFile = new FontFile;
|
||||||
|
fontFile->fileName = fileName;
|
||||||
|
fontFile->indexValue = indexValue;
|
||||||
|
QPlatformFontDatabase::registerFont(familyName,
|
||||||
|
styleName,
|
||||||
|
QLatin1StringView((const char *)foundry_value),
|
||||||
|
weight,
|
||||||
|
style,
|
||||||
|
stretch,
|
||||||
|
antialias,
|
||||||
|
scalable,
|
||||||
|
pixel_size,
|
||||||
|
fixedPitch,
|
||||||
|
colorFont,
|
||||||
|
writingSystems,
|
||||||
|
fontFile);
|
||||||
|
}
|
||||||
if (applicationFont != nullptr && face != nullptr && db != nullptr) {
|
if (applicationFont != nullptr && face != nullptr && db != nullptr) {
|
||||||
db->addNamedInstancesForFace(face,
|
db->addNamedInstancesForFace(face,
|
||||||
indexValue,
|
indexValue,
|
||||||
@ -549,8 +564,25 @@ static void populateFromPattern(FcPattern *pattern,
|
|||||||
|
|
||||||
applicationFont->properties.append(properties);
|
applicationFont->properties.append(properties);
|
||||||
}
|
}
|
||||||
FontFile *altFontFile = new FontFile(*fontFile);
|
|
||||||
QPlatformFontDatabase::registerFont(altFamilyName, altStyleName, QLatin1StringView((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,fixedPitch,colorFont,writingSystems,altFontFile);
|
{
|
||||||
|
FontFile *altFontFile = new FontFile;
|
||||||
|
altFontFile->fileName = fileName;
|
||||||
|
altFontFile->indexValue = indexValue;
|
||||||
|
QPlatformFontDatabase::registerFont(altFamilyName,
|
||||||
|
altStyleName,
|
||||||
|
QLatin1StringView((const char *)foundry_value),
|
||||||
|
weight,
|
||||||
|
style,
|
||||||
|
stretch,
|
||||||
|
antialias,
|
||||||
|
scalable,
|
||||||
|
pixel_size,
|
||||||
|
fixedPitch,
|
||||||
|
colorFont,
|
||||||
|
writingSystems,
|
||||||
|
altFontFile);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QPlatformFontDatabase::registerAliasToFontFamily(familyName, altFamilyName);
|
QPlatformFontDatabase::registerAliasToFontFamily(familyName, altFamilyName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user