Update AMFDeserialize (#1096)

Per ISO C++ standard 9.7.1 5.3,
"Otherwise the type of the enumerator is the same as that of the preceding enumerator unless the
incremented value is not representable in that type, in which case the type is an unspecified integral
type sufficient to contain the incremented value. If no such type exists, the program is ill-formed."
it is not undefined behavior to set a scoped enum to a value outside of its constant range because all values of the underlying type can represent the scoped enum
This commit is contained in:
David Markowitz 2023-06-02 04:44:49 -07:00 committed by GitHub
parent e47169fec5
commit 9fabff16e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,10 +13,8 @@ AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) {
if (!inStream) return nullptr; if (!inStream) return nullptr;
AMFBaseValue* returnValue = nullptr; AMFBaseValue* returnValue = nullptr;
// Read in the value type from the bitStream // Read in the value type from the bitStream
uint8_t i; eAmf marker;
inStream->Read(i); inStream->Read(marker);
if (i > static_cast<uint8_t>(eAmf::Dictionary)) return nullptr;
eAmf marker = static_cast<eAmf>(i);
// Based on the typing, create the value associated with that and return the base value class // Based on the typing, create the value associated with that and return the base value class
switch (marker) { switch (marker) {
case eAmf::Undefined: { case eAmf::Undefined: {