fix crash for case args == nullptr

master
Francisco Paisana 5 years ago
parent 1b958a60b5
commit d382c10948

@ -32,9 +32,14 @@ namespace srslte {
bool radio::init(log_filter* _log_h, const char* args, char* devname, uint32_t nof_channels) bool radio::init(log_filter* _log_h, const char* args, char* devname, uint32_t nof_channels)
{ {
std::vector<char> tmp_args(strlen(args) + 1); char* mutable_arg_str = nullptr;
strcpy(&tmp_args[0], args); std::vector<char> args_vec;
if (srslte_rf_open_devname(&rf_device, devname, &tmp_args[0], nof_channels)) { if (args != nullptr) {
args_vec.resize(strlen(args) + 1);
strcpy(&args_vec[0], args);
mutable_arg_str = &args_vec[0];
}
if (srslte_rf_open_devname(&rf_device, devname, mutable_arg_str, nof_channels)) {
ERROR("Error opening RF device\n"); ERROR("Error opening RF device\n");
return false; return false;
} }

Loading…
Cancel
Save