[PATCH 2/6] Fix memory leak on serial bluetooth

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


Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 qtserialbluetooth.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index ebbd1d4..442702d 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -54,8 +54,10 @@ static int qt_serial_open(serial_t **out, dc_context_t *context, const char* dev
 	// Create a RFCOMM socket
 	serial_port->socket = ::socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
 
-	if (serial_port->socket == INVALID_SOCKET)
+	if (serial_port->socket == INVALID_SOCKET) {
+		free(serial_port);
 		return DC_STATUS_IO;
+	}
 
 	SOCKADDR_BTH socketBthAddress;
 	int socketBthAddressBth = sizeof (socketBthAddress);
-- 
2.1.4



More information about the subsurface mailing list