From 2082845d0310672e2977e8c92d629ed1d781e1d4 Mon Sep 17 00:00:00 2001 From: Alexey Esaulenko Date: Thu, 18 Jan 2024 15:13:48 +0400 Subject: [PATCH] SocketCANd: fix memory leak: string can be accessed after object destruction --- connections/socketcand.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/connections/socketcand.cpp b/connections/socketcand.cpp index 83fb144..6ef8975 100644 --- a/connections/socketcand.cpp +++ b/connections/socketcand.cpp @@ -219,8 +219,8 @@ void SocketCANd::connectDevice() void SocketCANd::deviceConnected(int busNum) { sendDebug("Opening CAN on Kayak Device!"); - const char* openCanCmd = ("< open " + hostCanIDs[busNum] + " >").toStdString().c_str(); - sendStringToTCP(openCanCmd, busNum); + QString openCanCmd("< open " % hostCanIDs[busNum] % " >"); + sendStringToTCP(openCanCmd.toUtf8().data(), busNum); QCoreApplication::processEvents(); } @@ -383,8 +383,6 @@ void SocketCANd::procRXData(QString data, int busNum) mTimer.stop(); mTimer.start(); } - QByteArray output; - switch (rx_state.at(busNum)) { case IDLE: