From d382c10948beab9a09322531aee3dc389178e10e Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 31 Jan 2020 18:37:32 +0000 Subject: [PATCH] fix crash for case args == nullptr --- lib/src/radio/radio.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index e83049f18..d12c06844 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -32,9 +32,14 @@ namespace srslte { bool radio::init(log_filter* _log_h, const char* args, char* devname, uint32_t nof_channels) { - std::vector tmp_args(strlen(args) + 1); - strcpy(&tmp_args[0], args); - if (srslte_rf_open_devname(&rf_device, devname, &tmp_args[0], nof_channels)) { + char* mutable_arg_str = nullptr; + std::vector args_vec; + 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"); return false; }