Fix out of bounds access during QTextDocument cloning

Fixes: QTBUG-120962
Pick-to: 6.5 6.6 6.7
Change-Id: Ib2a35acd5a0d673b39556a4aa930e37eb40b39b2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Joni Poikelin 2024-01-23 09:51:01 +02:00
parent 3fd49e95a9
commit 96f1ef1c1c

View File

@ -3993,7 +3993,7 @@ bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const
int QTextFormatCollection::objectFormatIndex(int objectIndex) const
{
if (objectIndex == -1)
if (objectIndex == -1 || objectIndex >= objFormats.size())
return -1;
return objFormats.at(objectIndex);
}