soapy: fix segfault when launching and no device args where provided

master
Andre Puschmann 5 years ago
parent c82e7d313a
commit ed646de7f1

@ -302,20 +302,22 @@ int rf_soapy_open_multi(char* args, void** h, uint32_t num_requested_channels)
} }
// Select Soapy device by id // Select Soapy device by id
const char dev_arg[] = "id="; int dev_id = 0;
char* dev_ptr = strstr(args, dev_arg); if (args != NULL) {
int dev_id = 0; const char dev_arg[] = "id=";
if (dev_ptr) { char* dev_ptr = strstr(args, dev_arg);
char dev_str[64] = {0}; if (dev_ptr) {
copy_subdev_string(dev_str, dev_ptr + strnlen(dev_arg, 64)); char dev_str[64] = {0};
printf("Selecting Soapy device: %s\n", dev_str); copy_subdev_string(dev_str, dev_ptr + strnlen(dev_arg, 64));
dev_id = strtol(dev_str, NULL, 0); printf("Selecting Soapy device: %s\n", dev_str);
if (dev_id < 0 || dev_id > 10) { dev_id = strtol(dev_str, NULL, 0);
ERROR("Failed to set device. Using 0 as default.\n"); if (dev_id < 0 || dev_id > 10) {
dev_id = 0; ERROR("Failed to set device. Using 0 as default.\n");
} dev_id = 0;
remove_substring(args, dev_arg); }
remove_substring(args, dev_str); remove_substring(args, dev_arg);
remove_substring(args, dev_str);
}
} }
SoapySDRDevice* sdr = SoapySDRDevice_make(&(soapy_args[dev_id])); SoapySDRDevice* sdr = SoapySDRDevice_make(&(soapy_args[dev_id]));

Loading…
Cancel
Save