QStringRef: document that passing a string longer than INT_MAX is UB
Since the class uses int to represent the size, passing a QString
longer than INT_MAX silently truncates to int, which can result in a
negative value. This negative value is then used in offset calculation,
and as a parameter to memcpy() in QStringBuilder.
We could fix it by limiting the input to INT_MAX in such case, but the
code is inline, so the users would need to recompile anyway.
We already have another constructor that explicitly takes a string,
a position in that string, and the length of the chunk. And that
constructor explicitly documents that it does not check against negative
parameters. So, follow the same logic here, and document that the input
string should not be longer than INT_MAX.
Add a Security Considerations section to the class' docs and mention
the int-related limitations there. Recommend using QStringView instead.
Fixes: QTBUG-149430
Pick-to: 6.12 6.11 6.8
Change-Id: Ic277b9c46f76fc475840a2ad1aa51f12ebd00e22
Reviewed-by: Marc Mutz <marc.mutz@qt.io>