From 3e0918c768a5b5a4cb64dc3186f5215794e34ed1 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 14 Dec 2017 23:12:52 +0100 Subject: [PATCH] Web API: fixed segfault in WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch --- sdrgui/webapi/webapiadaptergui.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index 44e1333a4..1489b1855 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -746,7 +746,12 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch( if (deviceSet->m_deviceSourceEngine) // Rx { - if ((response.getTx() != 0) || (deviceSet->m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType())) + if (response.getTx() != 0) + { + *error.getMessage() = QString("Rx device found but Tx device requested"); + return 400; + } + if (deviceSet->m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType()) { *error.getMessage() = QString("Device mismatch. Found %1 input").arg(deviceSet->m_deviceSourceAPI->getHardwareId()); return 400; @@ -759,9 +764,14 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch( } else if (deviceSet->m_deviceSinkEngine) // Tx { - if ((response.getTx() == 0) || (deviceSet->m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType())) + if (response.getTx() == 0) { - *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceSourceAPI->getHardwareId()); + *error.getMessage() = QString("Tx device found but Rx device requested"); + return 400; + } + else if (deviceSet->m_deviceSinkAPI->getHardwareId() != *response.getDeviceHwType()) + { + *error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceSinkAPI->getHardwareId()); return 400; } else