Fix out of bounds access during QTextDocument cloning

Fixes: QTBUG-120962
Pick-to: 6.6 6.5
Change-Id: Ib2a35acd5a0d673b39556a4aa930e37eb40b39b2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 96f1ef1c1c43a965697022f99105c11613129e3d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joni Poikelin 2024-01-23 09:51:01 +02:00 committed by Qt Cherry-pick Bot
parent 65a1becad2
commit 7878c8b6f3

View File

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