Delay freeing of memory after use

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2015-09-09 18:34:49 +03:00 committed by Dirk Hohndel
parent ce608b7ecf
commit 43627922e0

View file

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