compatibility bits for converting strings starting with negative sign to unsigned integer

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-06-19 20:34:38 +03:00
parent e8bf4fd137
commit ed371fbd0f

View file

@ -2470,7 +2470,9 @@ qlonglong QLocalePrivate::bytearrayToLongLong(const char *num, int base, bool *o
qulonglong QLocalePrivate::bytearrayToUnsLongLong(const char *num, int base, bool *ok)
{
if (Q_UNLIKELY(*num == '\0')) {
// for compatibility strings starting with negative sign shall return 0 and set ok to false,
// standard C library implementation handles it like overflow
if (Q_UNLIKELY(*num == '\0' || *num == '-')) {
if (ok != Q_NULLPTR)
*ok = false;
return 0;