Browse Source

plutosdr: guard against null scan description

Add a null check for the IIO scan context description before using it
to construct a std::string or std::string_view.

This also makes the non-null assumption explicit for static analysis and
fixes Coverity CID 652283 (FORWARD_NULL).

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
6d786dec7c
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 4
      devices/plutosdr/deviceplutosdrscan.cpp

4
devices/plutosdr/deviceplutosdrscan.cpp

@ -61,7 +61,7 @@ void DevicePlutoSDRScan::scan() @@ -61,7 +61,7 @@ void DevicePlutoSDRScan::scan()
const char *description = iio_context_info_get_description(info[i]);
const char *uri = iio_context_info_get_uri(info[i]);
if (!DevicePlutoSDRBox::probeURI(std::string(uri))) { // continue if not accessible
if (!DevicePlutoSDRBox::probeURI(std::string(uri)) || !description) {
continue;
}
@ -69,7 +69,7 @@ void DevicePlutoSDRScan::scan() @@ -69,7 +69,7 @@ void DevicePlutoSDRScan::scan()
std::string fixedUri = replaceHostnameWithIP(uri, description);
qDebug("PlutoSDRScan::scan: %d: %s [%s] [%s]", i, description, uri, fixedUri.c_str());
const std::string_view descriptionView = description ? std::string_view{description} : std::string_view{};
const std::string_view descriptionView = std::string_view{description};
const bool isPlutoDescription =
(descriptionView.find("PlutoSDR") != std::string_view::npos) ||
(descriptionView.find("AD93") != std::string_view::npos);

Loading…
Cancel
Save