1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-15 22:34:58 +00:00

Fix bug: avoid RTKLIB memory corruption

Avoid alloc-dealloc-mismatch caused by uniqnav
Reserve memory for get_PVT as std::arrays in header file, so we do not have to ask for new memory each time we execute get_PVT
Remove unused public member count_valid_position
This commit is contained in:
Carles Fernandez 2019-07-28 13:59:29 +02:00
parent 9f8f9e8af9
commit 271399fc22
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 13 additions and 7 deletions

View File

@ -94,7 +94,6 @@ Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag
d_dump_filename = std::move(dump_filename);
d_flag_dump_enabled = flag_dump_to_file;
d_flag_dump_mat_enabled = flag_dump_to_mat;
count_valid_position = 0;
this->set_averaging_flag(false);
rtk_ = rtk;
@ -443,9 +442,9 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
int valid_obs = 0; // valid observations counter
int glo_valid_obs = 0; // GLONASS L1/L2 valid observations counter
std::array<obsd_t, MAXOBS> obs_data{};
std::vector<eph_t> eph_data(MAXOBS);
std::vector<geph_t> geph_data(MAXOBS);
obs_data.fill({});
eph_data.fill({});
geph_data.fill({});
// Workaround for NAV/CNAV clash problem
bool gps_dual_band = false;
@ -914,7 +913,13 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
}
/* update carrier wave length using native function call in RTKlib */
uniqnav(&nav_data);
for (int i = 0; i < MAXSAT; i++)
{
for (int j = 0; j < NFREQ; j++)
{
nav_data.lam[i][j] = satwavelen(i + 1, j, &nav_data);
}
}
result = rtkpos(&rtk_, obs_data.data(), valid_obs + glo_valid_obs, &nav_data);

View File

@ -126,8 +126,6 @@ public:
Beidou_Dnav_Iono beidou_dnav_iono;
std::map<int, Beidou_Dnav_Almanac> beidou_dnav_almanac_map;
int count_valid_position;
private:
rtk_t rtk_{};
std::string d_dump_filename;
@ -137,6 +135,9 @@ private:
bool d_flag_dump_mat_enabled;
int d_nchannels; // Number of available channels for positioning
std::array<double, 4> dop_{};
std::array<obsd_t, MAXOBS> obs_data{};
std::array<eph_t, MAXOBS> eph_data{};
std::array<geph_t, MAXOBS> geph_data{};
Monitor_Pvt monitor_pvt{};
};