[PATCH 1/6] Delay freeing of memory after use

Miika Turkia miika.turkia at gmail.com
Wed Sep 9 21:19:02 PDT 2015


Signed-off-by: Miika Turkia <miika.turkia at 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



More information about the subsurface mailing list