Fix QLocale::createSeparatedList() for lists > 2Gi items

... by not truncating qsizetype sizes to int.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-105047
Change-Id: Iedb682e6649d4511073b33011f8fcc428f968422
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2022-07-18 17:52:43 +02:00
parent 5983f8d47d
commit fcd96a441d

View File

@ -1216,7 +1216,7 @@ QString QLocale::createSeparatedList(const QStringList &list) const
}
#endif
const int size = list.size();
const qsizetype size = list.size();
if (size < 1)
return QString();
@ -1231,7 +1231,7 @@ QString QLocale::createSeparatedList(const QStringList &list) const
QStringView formatMid = d->m_data->midListPattern().viewData(list_pattern_part_data);
QStringView formatEnd = d->m_data->endListPattern().viewData(list_pattern_part_data);
QString result = formatStart.arg(list.at(0), list.at(1));
for (int i = 2; i < size - 1; ++i)
for (qsizetype i = 2; i < size - 1; ++i)
result = formatMid.arg(result, list.at(i));
result = formatEnd.arg(result, list.at(size - 1));
return result;