Memory Leak in Drive Scanning

This commit is contained in:
2025-12-07 18:44:53 +01:00
parent 37cbc9500e
commit ff6a1763e0

View File

@ -326,28 +326,28 @@ void reHDD::searchDrives(std::list<Drive> *plistDrives)
if (devName.empty()) if (devName.empty())
continue; continue;
Drive *tmpDrive = new Drive("/dev/" + devName); Drive tmpDrive("/dev/" + devName);
tmpDrive->state = Drive::NONE; tmpDrive.state = Drive::NONE;
tmpDrive->bIsOffline = false; tmpDrive.bIsOffline = false;
// Set connection type // Set connection type
if (transport == "sata") if (transport == "sata")
tmpDrive->connectionType = Drive::SATA; tmpDrive.connectionType = Drive::SATA;
else if (transport == "usb") else if (transport == "usb")
tmpDrive->connectionType = Drive::USB; tmpDrive.connectionType = Drive::USB;
else if (transport == "nvme") else if (transport == "nvme")
tmpDrive->connectionType = Drive::NVME; tmpDrive.connectionType = Drive::NVME;
else else
tmpDrive->connectionType = Drive::UNKNOWN; tmpDrive.connectionType = Drive::UNKNOWN;
plistDrives->push_back(*tmpDrive); plistDrives->push_back(tmpDrive);
Logger::logThis()->info( Logger::logThis()->info(
"Drive found: " + tmpDrive->getPath() + "Drive found: " + tmpDrive.getPath() +
" (type: " + " (type: " +
(tmpDrive->connectionType == Drive::USB ? "USB" : tmpDrive->connectionType == Drive::SATA ? "SATA" (tmpDrive.connectionType == Drive::USB ? "USB" : tmpDrive.connectionType == Drive::SATA ? "SATA"
: tmpDrive->connectionType == Drive::NVME ? "NVME" : tmpDrive.connectionType == Drive::NVME ? "NVME"
: "UNKNOWN") + : "UNKNOWN") +
")"); ")");
} }