mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 14:58:27 +00:00
reinterpret_cast-based type-punning is almost always UB
This commit is contained in:
@@ -159,8 +159,7 @@ void RakNet::BitStream::Write<AMFIntValue&>(AMFIntValue& value) {
|
||||
// Writes an AMFDoubleValue to BitStream
|
||||
template<>
|
||||
void RakNet::BitStream::Write<AMFDoubleValue&>(AMFDoubleValue& value) {
|
||||
double d = value.GetValue();
|
||||
WriteAMFU64(*this, *reinterpret_cast<uint64_t*>(&d));
|
||||
WriteAMFU64(*this, std::bit_cast<uint64_t>(value.GetValue()));
|
||||
}
|
||||
|
||||
// Writes an AMFStringValue to BitStream
|
||||
|
@@ -146,7 +146,7 @@ void WriteSd0Magic(char* input, uint32_t chunkSize) {
|
||||
input[2] = '0';
|
||||
input[3] = 0x01;
|
||||
input[4] = 0xFF;
|
||||
*reinterpret_cast<uint32_t*>(input + 5) = chunkSize; // Write the integer to the character array
|
||||
std::memcpy(&input[5], &chunkSize, sizeof(uint32_t)); // Write the integer to the character array
|
||||
}
|
||||
|
||||
bool CheckSd0Magic(std::istream& streamToCheck) {
|
||||
|
@@ -53,7 +53,7 @@ bool static _IsSuffixChar(const uint8_t c) {
|
||||
bool GeneralUtils::details::_NextUTF8Char(std::string_view& slice, uint32_t& out) {
|
||||
const size_t rem = slice.length();
|
||||
if (slice.empty()) return false;
|
||||
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&slice.front());
|
||||
const auto* bytes = &slice.front();
|
||||
if (rem > 0) {
|
||||
const uint8_t first = bytes[0];
|
||||
if (first < 0x80) { // 1 byte character
|
||||
|
Reference in New Issue
Block a user