diff --git a/src/FitRideFile.cpp b/src/FitRideFile.cpp index 27ddecfd9..69ec8b971 100644 --- a/src/FitRideFile.cpp +++ b/src/FitRideFile.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -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;