diff --git a/src/corelib/global/qtenvironmentvariables.cpp b/src/corelib/global/qtenvironmentvariables.cpp index ae213aa1e39..ffafbdf4180 100644 --- a/src/corelib/global/qtenvironmentvariables.cpp +++ b/src/corelib/global/qtenvironmentvariables.cpp @@ -10,6 +10,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -253,11 +254,10 @@ std::optional qEnvironmentVariableIntegerValue(const char *varName) noexcep if (!buffer || (size = strlen(buffer)) > MaxDigitsForOctalInt) return std::nullopt; #endif - bool ok; - int value = QByteArrayView(buffer, size).toInt(&ok, 0); - if (!ok) + auto r = QLocaleData::bytearrayToLongLong(QByteArrayView(buffer, size), 0); + if (!r.ok() || int(r.result) != r.result) return std::nullopt; - return value; + return r.result; } /*!