Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qtserialbluetooth.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index 45fc8d1..ebbd1d4 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -151,12 +151,12 @@ static int qt_serial_open(serial_t **out, dc_context_t 
*context, const char* dev
        }
 #endif
        if (serial_port->socket->state() != QBluetoothSocket::ConnectedState) {
-               free (serial_port);
 
                // Get the latest error and try to match it with one from 
libdivecomputer
                QBluetoothSocket::SocketError err = 
serial_port->socket->error();
                qDebug() << "Failed to connect to device " << devaddr << ". 
Device state " << serial_port->socket->state() << ". Error: " << err;
 
+               free (serial_port);
                switch(err) {
                case QBluetoothSocket::HostNotFoundError:
                case QBluetoothSocket::ServiceNotFoundError:
-- 
2.1.4

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to