mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
FitRideFile: turned assertions into graceful fail
reading Fit files with Smart recording and a certain pattern of timestamps could cause assertions. This shouldn't happen, as it's no Programming error. Changed the checks into graceful failures. Unfortunatly I don't have any files to test this. fixes #364
This commit is contained in:
committed by
Gareth Coco
parent
ee79a86c1f
commit
1674558dbb
@@ -22,7 +22,6 @@
|
||||
#include <QSet>
|
||||
#include <QtEndian>
|
||||
#include <QDebug>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <limits>
|
||||
@@ -78,6 +77,7 @@ struct FitFileReaderState
|
||||
}
|
||||
|
||||
struct TruncatedRead {};
|
||||
struct BadDelta {};
|
||||
|
||||
void read_unknown( int size, int *count = NULL ){
|
||||
char c[size+1];
|
||||
@@ -388,9 +388,11 @@ struct FitFileReaderState
|
||||
// Evil smart recording. Linearly interpolate missing points.
|
||||
RideFilePoint *prevPoint = rideFile->dataPoints().back();
|
||||
int deltaSecs = (int) (secs - prevPoint->secs);
|
||||
assert(deltaSecs == secs - prevPoint->secs); // no fractional part
|
||||
if(deltaSecs != secs - prevPoint->secs)
|
||||
throw BadDelta(); // no fractional part
|
||||
// This is only true if the previous record was of type record:
|
||||
assert(deltaSecs == time - last_time);
|
||||
if(deltaSecs != time - last_time)
|
||||
throw BadDelta();
|
||||
// If the last lat/lng was missing (0/0) then all points up to lat/lng are marked as 0/0.
|
||||
if (prevPoint->lat == 0 && prevPoint->lon == 0 ) {
|
||||
badgps = 1;
|
||||
@@ -571,6 +573,11 @@ struct FitFileReaderState
|
||||
delete rideFile;
|
||||
return NULL;
|
||||
}
|
||||
catch (BadDelta &e) {
|
||||
errors << "Unsupported smart recording interval found";
|
||||
delete rideFile;
|
||||
return NULL;
|
||||
}
|
||||
if (stop) {
|
||||
delete rideFile;
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user