From a32ad7f1f26c9b708ec87aa694cb70ae25dcbb94 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 1 May 2020 22:27:08 -0400 Subject: [PATCH] soc_u: Prevent undefined behavior with CTRPollFD This class is memcpy-ed and memcpy has the requirement that data passed to it must be trivially copyable, otherwise the behavior is undefined. This is trivial to resolve as BitField was made trivially copyable a while ago, so this explicit copy assignment operator isn't necessary. --- src/core/hle/service/soc_u.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index d45832a43..3620b458c 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "common/archives.h" #include "common/assert.h" @@ -199,11 +200,6 @@ struct CTRPollFD { BitField<4, 1, u32> pollout; BitField<5, 1, u32> pollnval; - Events& operator=(const Events& other) { - hex = other.hex; - return *this; - } - /// Translates the resulting events of a Poll operation from platform-specific to 3ds /// specific static Events TranslateTo3DS(u32 input_event) { @@ -263,6 +259,8 @@ struct CTRPollFD { return result; } }; +static_assert(std::is_trivially_copyable_v, + "CTRPollFD is used with std::memcpy and must be trivially copyable"); /// Union to represent the 3ds' sockaddr structure union CTRSockAddr {