From 9fabff16e49994dd6513c64f22fe6b3f72dcd6ae Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Fri, 2 Jun 2023 04:44:49 -0700 Subject: [PATCH] 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 --- dCommon/AMFDeserialize.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dCommon/AMFDeserialize.cpp b/dCommon/AMFDeserialize.cpp index 9eee1f12..648d1ed1 100644 --- a/dCommon/AMFDeserialize.cpp +++ b/dCommon/AMFDeserialize.cpp @@ -13,10 +13,8 @@ AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) { if (!inStream) return nullptr; AMFBaseValue* returnValue = nullptr; // Read in the value type from the bitStream - uint8_t i; - inStream->Read(i); - if (i > static_cast(eAmf::Dictionary)) return nullptr; - eAmf marker = static_cast(i); + eAmf marker; + inStream->Read(marker); // Based on the typing, create the value associated with that and return the base value class switch (marker) { case eAmf::Undefined: {