solid: plug memory leak in devinfo backend

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-09-02 03:52:59 +03:00
parent 7ecb69bd0a
commit 5c2c878f82

View file

@ -76,18 +76,19 @@ DevinfoDevice::DevinfoDevice(const QString &device)
return;
}
const QByteArray devicename = m_device.right(m_device.size() - qstrlen(DEVINFO_UDI_PREFIX) - 1).toLatin1();
DeviceArgumentType* getDeviceArg = new DeviceArgumentType(devicename, m_properties);
struct devinfo_dev *root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE);
if (root) {
const QByteArray devicename = m_device.right(m_device.size() - qstrlen(DEVINFO_UDI_PREFIX) - 1).toLatin1();
DeviceArgumentType* getDeviceArg = new DeviceArgumentType(devicename, m_properties);
devinfo_foreach_device_child(root, getDeviceProperties, getDeviceArg);
m_properties = getDeviceArg->second;
delete getDeviceArg;
} else {
qWarning() << "no root device";
return;
}
m_properties = getDeviceArg->second;
delete getDeviceArg;
const QByteArray pnpinfo = m_properties[DevinfoDevice::DevicePnPInfo];
m_pnpinfo[DevinfoDevice::PnPVendor] = getPnPInfo(pnpinfo, "vendor");