1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-10 20:10:05 +00:00

Fix segmentation fault if the SignalSource implementation is not available

This commit is contained in:
Carles Fernandez 2024-08-08 10:38:52 +02:00
parent ef1cb81784
commit 7ff1d9006e
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 10 additions and 2 deletions

View File

@ -113,6 +113,7 @@
#include "tracking_interface.h" #include "tracking_interface.h"
#include "two_bit_cpx_file_signal_source.h" #include "two_bit_cpx_file_signal_source.h"
#include "two_bit_packed_file_signal_source.h" #include "two_bit_packed_file_signal_source.h"
#include <cstdlib> // for exit
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cerr #include <iostream> // for cerr
#include <utility> // for move #include <utility> // for move

View File

@ -48,6 +48,7 @@
#include <algorithm> // for transform, sort, unique #include <algorithm> // for transform, sort, unique
#include <cmath> // for floor #include <cmath> // for floor
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <cstdlib> // for exit
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for operator<< #include <iostream> // for operator<<
#include <iterator> // for insert_iterator, inserter #include <iterator> // for insert_iterator, inserter
@ -124,9 +125,15 @@ void GNSSFlowgraph::init()
sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated); sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated);
// Avoid segmentation fault caused by wrong configuration // 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"; std::cout << " if you are using the Multichannel_File_Signal_Source implementation.\n";
sources_count_ = 1; sources_count_ = 1;
} }