Fix rare crashes in fontconfig fontdb due to uninitialized variable

Initialize the out variable passed to FcPatternGetString to protect
against the "failure" case. Otherwise the subsequent QString::fromUtf8
is called with an uninitialized pointer.

Change-Id: I31b8b4c366f673609b26eca162334fd8bc9f25d2
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
This commit is contained in:
Simon Hausmann 2012-01-04 13:04:58 +01:00 committed by Qt by Nokia
parent 08863b6fda
commit bd525a64d5

View File

@ -724,7 +724,7 @@ QString QFontconfigDatabase::resolveFontFamilyAlias(const QString &family) const
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcChar8 *familyAfterSubstitution;
FcChar8 *familyAfterSubstitution = 0;
FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution);
QString resolved = QString::fromUtf8((const char *) familyAfterSubstitution);
FcPatternDestroy(pattern);