mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 04:04:09 +01:00
Codefix: StringConsumer integer parsing failed for the most negative value, which has no positive equivalent. (#14048)
This commit is contained in:
@@ -813,10 +813,10 @@ private:
|
||||
|
||||
/* Try negative hex */
|
||||
if (std::is_signed_v<T> && (src.starts_with("-0x") || src.starts_with("-0X"))) {
|
||||
using Unsigned = std::make_signed_t<T>;
|
||||
using Unsigned = std::make_unsigned_t<T>;
|
||||
auto [len, uvalue] = ParseIntegerBase<Unsigned>(src.substr(3), 16, log_errors);
|
||||
if (len == 0) return {};
|
||||
T value = -uvalue;
|
||||
T value = static_cast<T>(0 - uvalue);
|
||||
if (value > 0) {
|
||||
if (log_errors) LogError(fmt::format("Integer out of range: '{}'", src.substr(0, len + 3)));
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user