Skip to content

Commit 53af63e

Browse files
committed
Fix use after free.
1 parent d926747 commit 53af63e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ std::unique_ptr<ControllerConnection> SwitchController_SerialPABotBase_Descripto
9696

9797

9898

99+
SwitchController_SerialPABotBase::~SwitchController_SerialPABotBase(){
100+
m_handle.disconnect();
101+
}
99102
SwitchController_SerialPABotBase::SwitchController_SerialPABotBase(
100103
Logger& logger,
101104
const SwitchController_SerialPABotBase_Descriptor& descriptor,
@@ -124,9 +127,9 @@ SwitchController_SerialPABotBase::SwitchController_SerialPABotBase(
124127
}
125128
)
126129
, m_logger(logger, GlobalSettings::instance().LOG_EVERYTHING)
130+
, m_logging_suppress(0)
127131
, m_handle(m_logger, &descriptor.port(), requirements)
128132
, m_serial(*m_handle.botbase())
129-
, m_logging_suppress(0)
130133
{
131134
m_handle.connect(
132135
&m_handle, &BotBaseHandle::on_not_connected,

SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_SerialPABotBase.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class SwitchController_SerialPABotBase :
9292
using ContextType = SwitchControllerContext;
9393

9494
public:
95+
~SwitchController_SerialPABotBase();
9596
SwitchController_SerialPABotBase(
9697
Logger& logger,
9798
const SwitchController_SerialPABotBase_Descriptor& descriptor,
@@ -203,15 +204,16 @@ class SwitchController_SerialPABotBase :
203204

204205
private:
205206
SerialLogger m_logger;
206-
BotBaseHandle m_handle;
207207

208208
std::string m_status;
209209
std::string m_uptime;
210210

211-
BotBaseController& m_serial;
212211

213212
std::atomic<size_t> m_logging_suppress;
214213
SpinLock m_lock;
214+
215+
BotBaseHandle m_handle;
216+
BotBaseController& m_serial;
215217
};
216218

217219

0 commit comments

Comments
 (0)