mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Fix UB in to_u8
Possible signed shift overflow.
This commit is contained in:
parent
abe2cc196a
commit
baf9a20c08
1 changed files with 2 additions and 2 deletions
|
@ -529,7 +529,7 @@ struct offset32_detail<T3 T4::*>
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function, used by ""_u16, ""_u32, ""_u64
|
// Helper function, used by ""_u16, ""_u32, ""_u64
|
||||||
constexpr u8 to_u8(char c)
|
constexpr u32 to_u8(char c)
|
||||||
{
|
{
|
||||||
return static_cast<u8>(c);
|
return static_cast<u8>(c);
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ constexpr u16 operator""_u16(const char* s, std::size_t length)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
#if IS_LE_MACHINE == 1
|
#if IS_LE_MACHINE == 1
|
||||||
to_u8(s[1]) << 8 | to_u8(s[0]);
|
static_cast<u16>(to_u8(s[1]) << 8 | to_u8(s[0]));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue