From 288ff3565efdff047e707c092143a967e8c5eeae Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 14 May 2019 15:20:04 -0400 Subject: [PATCH] Make sure to close underlying com if we fail to open --- device/device.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/device/device.cpp b/device/device.cpp index 741286e..0d121a8 100644 --- a/device/device.cpp +++ b/device/device.cpp @@ -151,13 +151,15 @@ bool Device::open() { break; } if(!serial) { - err(APIError::NoSerialNumber); + err(APIError::NoSerialNumber); // Communication could not be established with the device. Perhaps it is not powered with 12 volts? + com->close(); return false; } std::string currentSerial = getNeoDevice().serial; if(currentSerial != serial->deviceSerial) { err(APIError::IncorrectSerialNumber); + com->close(); return false; }