diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 1a48e0a7f..dda8452a8 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -113,6 +113,7 @@ #include "tracking_interface.h" #include "two_bit_cpx_file_signal_source.h" #include "two_bit_packed_file_signal_source.h" +#include // for exit #include // for exception #include // for cerr #include // for move diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 957077eca..5b2b9d7f4 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -48,6 +48,7 @@ #include // for transform, sort, unique #include // for floor #include // for size_t +#include // for exit #include // for exception #include // for operator<< #include // for insert_iterator, inserter @@ -124,9 +125,15 @@ void GNSSFlowgraph::init() sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated); // Avoid segmentation fault caused by wrong configuration - if (sources_count_ == 2 && block_factory->GetSignalSource(configuration_.get(), queue_.get(), 0)->implementation() == "Multichannel_File_Signal_Source") + auto check_not_nullptr = block_factory->GetSignalSource(configuration_.get(), queue_.get(), 0); + if (!check_not_nullptr) { - std::cout << " * Please set GNSS-SDR.num_sources=1 in your configuraiion file\n"; + std::cout << "GNSS-SDR program ended.\n"; + exit(1); + } + if (sources_count_ == 2 && check_not_nullptr->implementation() == "Multichannel_File_Signal_Source") + { + std::cout << " * Please set GNSS-SDR.num_sources=1 in your configuration file\n"; std::cout << " if you are using the Multichannel_File_Signal_Source implementation.\n"; sources_count_ = 1; }