From 47e65794986e2b926448b3c7f99628eec40b6bb8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 23 Jul 2016 18:50:32 +0300 Subject: [PATCH] Don't leak memory if JsDevice constructor throws --- source/input/linux/gamecontroller.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/input/linux/gamecontroller.cpp b/source/input/linux/gamecontroller.cpp index 8a4e8d4..2fc624e 100644 --- a/source/input/linux/gamecontroller.cpp +++ b/source/input/linux/gamecontroller.cpp @@ -12,10 +12,12 @@ namespace Msp { namespace Input { GameController::GameController(unsigned index): - priv(new Private), event_disp(0) { - priv->dev = new JsDevice(format("/dev/input/js%d", index)); + JsDevice *device = new JsDevice(format("/dev/input/js%d", index)); + + priv = new Private; + priv->dev = device; priv->dev->signal_data_available.connect(sigc::mem_fun(this, static_cast(&GameController::tick))); name = priv->dev->get_name(); tick(Time::zero); -- 2.43.0