mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
planner: avoid out-of-bound access when initializing the planner
For dives with many samples (i.e. logged dives), samples are merged. I'm not exactly sure how this code works, but it does an out-of-bound access in some cases. Avoid that by a simple check. That said, I wonder if this downsampling is a good idea. A user reports that they have logged dives marked as manually added dives. We now load them into edit mode, which means a significant loss of information. Perhaps we should consider dives with more than 100 samples as non-manual dives? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
063a20a406
commit
687f65bf77
1 changed files with 2 additions and 2 deletions
|
@ -147,10 +147,10 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn)
|
|||
break;
|
||||
while (j * plansamples <= i * dc->samples) {
|
||||
const sample &s = dc->sample[j];
|
||||
const sample &prev = dc->sample[j-1];
|
||||
if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
|
||||
depthsum += s.depth.mm;
|
||||
last_sp = prev.setpoint;
|
||||
if (j > 0)
|
||||
last_sp = dc->sample[j-1].setpoint;
|
||||
++samplecount;
|
||||
newtime = s.time;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue