mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix memory leak in RideFile::append and friends
.. data point allocated twice on heap in appendOrUpdatePoint which is always called by RideFile::append .. this leak has been present since v3.4 (!) Fixes #4248
This commit is contained in:
@@ -1506,7 +1506,9 @@ void RideFile::appendOrUpdatePoint(double secs, double cad, double hr, double km
|
||||
rvert, rcad, rcontact, tcore,
|
||||
interval);
|
||||
|
||||
|
||||
if (!forceAppend) {
|
||||
|
||||
int idx = timeIndex(secs);
|
||||
if (idx != -1) {
|
||||
if (dataPoints_.at(idx)->secs == secs) {
|
||||
@@ -1519,21 +1521,10 @@ void RideFile::appendOrUpdatePoint(double secs, double cad, double hr, double km
|
||||
dataPoints_.insert(idx+1, point);
|
||||
}
|
||||
} else
|
||||
forceAppend = true;
|
||||
forceAppend = true; // note if clause below
|
||||
}
|
||||
|
||||
if (forceAppend) {
|
||||
RideFilePoint* point = new RideFilePoint(secs, cad, hr, km, kph, nm, watts, alt, lon, lat,
|
||||
headwind, slope, temp,
|
||||
lrbalance,
|
||||
lte, rte, lps, rps,
|
||||
lpco, rpco,
|
||||
lppb, rppb, lppe, rppe,
|
||||
lpppb, rpppb, lpppe, rpppe,
|
||||
smo2, thb,
|
||||
rvert, rcad, rcontact, tcore,
|
||||
interval);
|
||||
|
||||
if (forceAppend) { // note forceAppend = true above do not convert to else clause
|
||||
dataPoints_.append(point);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user