mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Added overflow handling in JsonVariant::as<T>() and JsonVariant::is<T>()
This commit is contained in:
@@ -79,8 +79,7 @@ class MsgPackDeserializer {
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
return readInteger<uint64_t>(variant);
|
||||
#else
|
||||
readInteger<uint32_t>();
|
||||
return readInteger<uint32_t>(variant);
|
||||
return DeserializationError::NotSupported;
|
||||
#endif
|
||||
|
||||
case 0xd0:
|
||||
@@ -96,8 +95,7 @@ class MsgPackDeserializer {
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
return readInteger<int64_t>(variant);
|
||||
#else
|
||||
if (!skip(4)) return DeserializationError::IncompleteInput;
|
||||
return readInteger<int32_t>(variant);
|
||||
return DeserializationError::NotSupported;
|
||||
#endif
|
||||
|
||||
case 0xca:
|
||||
|
||||
@@ -24,7 +24,8 @@ class MsgPackSerializer {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename enable_if<sizeof(T) == 8>::type visitFloat(T value64) {
|
||||
typename enable_if<sizeof(T) == 8>::type visitFloat(T value64)
|
||||
ARDUINOJSON_NO_SANITIZE("float-cast-overflow") {
|
||||
float value32 = float(value64);
|
||||
if (value32 == value64) {
|
||||
writeByte(0xCA);
|
||||
|
||||
Reference in New Issue
Block a user