From: Mikko Rasa Date: Sat, 23 Jul 2016 15:50:32 +0000 (+0300) Subject: Don't leak memory if JsDevice constructor throws X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=47e65794986e2b926448b3c7f99628eec40b6bb8;p=libs%2Fgui.git Don't leak memory if JsDevice constructor throws --- 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);