QStringRef: fix UB (signed overflow) in at()


In Qt 6, on 64-bit platforms, the underlying QString can hold more
than 2Gi characters, and a QStringRef, even though limited in
position() and size() to < INT_MAX, can legitimately reference a
portion of the QString that reaches beyond INT_MAX,
e.g. QStringRef(&s, INT_MAX/2, INT_MAX) on a 1.5*INT_MAX-sized 's'.

In that case, the addition of at()'s argument to m_position can
overflow, which a) is UB and b) can false-positively raise a Q_ASSERT
in QString::at().

To fix, do the calculation in qsizetype space.

As a drive-by, replace Q_ASSERT with Q_PRE.

Amends the port of QString from int to qsizetype size_type (6.0).

Pick-to: 6.12 6.11 6.8 6.5
Change-Id: Ied0f11b83d6e90b1e71c55089b99513f7f4b767e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
commit893e380f102ba2cb7f119aea2868225115e8cfa3
parentf93f871f73102730d60c0a2e31f5c28cb79e2e3c
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeFri, 28 Aug 2026 19:36:55 +0000