ICU: Fix crash in codecForMib(2107)

availableMibs() unconditionally adds 2107 to the list of mibs. The patch
ensures that codecForMib() also knows about this special TSCII codec.

(Note that the autotest only really checks this code path if only this
test case is run. The other tests already fill the internal codec cache
otherwise).

Change-Id: Id987d7cecd5f5700cca75e9b85b37011f8e5c622
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Kai Koehne 2012-08-22 13:51:45 +02:00 committed by Qt by Nokia
parent e9bc07c4f2
commit e177a35dfe
2 changed files with 12 additions and 0 deletions

View File

@ -530,6 +530,10 @@ QTextCodec *QIcuCodec::codecForMibUnlocked(int mib)
if (mibToName[i].mib == mib)
return codecForNameUnlocked(mibToNameTable + mibToName[i].index);
}
if (mib == 2107)
return codecForNameUnlocked("TSCII");
return 0;
}

View File

@ -73,6 +73,7 @@ private slots:
void decode0D() const;
void aliasForUTF16() const;
void mibForTSCII() const;
void codecForTSCII() const;
void utf8Codec_data();
void utf8Codec();
@ -513,6 +514,13 @@ void tst_QTextCodec::mibForTSCII() const
QCOMPARE(codec->mibEnum(), 2107);
}
void tst_QTextCodec::codecForTSCII() const
{
QTextCodec *codec = QTextCodec::codecForMib(2107);
QVERIFY(codec);
QCOMPARE(codec->mibEnum(), 2107);
}
static QString fromInvalidUtf8Sequence(const QByteArray &ba)
{
return QString().fill(QChar::ReplacementCharacter, ba.size());