Skip to content

Commit

Permalink
[#77] Data mining (Part 10: Fixed crash due to buffer overrun)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-nestorovic committed Sep 4, 2024
1 parent 1080e41 commit 3331fe3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Main/src/CapsBase_Mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
const CString trackName;
const Utils::CRidePen minedTimingPen;
const Utils::CRidePen minedIndexPen;
const Utils::CCallocPtr<POINT> minedTrackDeltaTiming;
Utils::CCallocPtr<POINT> minedTrackDeltaTiming;
POINT minedTrackIndices[Revolution::MAX+1];
struct TGraphics sealed{
CChartView::PCGraphics list[2];
Expand Down Expand Up @@ -155,6 +155,8 @@
// . timing
const auto iTimeStride=Utils::RoundDivUp( trw.GetTimesCount(), (DWORD)MINED_TRACK_TIMES_COUNT_MAX ); // round up so that we never overrun the buffer
const PCLogTime trackTiming=trw.GetBuffer();
if (minedTrackDeltaTiming.length<trw.GetTimesCount())
minedTrackDeltaTiming.Realloc( trw.GetTimesCount()+1000 ); // avoid excessive reallocations by allowing some reserve
LPPOINT pxy=minedTrackDeltaTiming;
for( DWORD i=1; i<trw.GetTimesCount(); i+=iTimeStride,pxy++ ){
pxy->x=trackTiming[i];
Expand Down Expand Up @@ -334,7 +336,6 @@
, headCalibration( (THeadCalibration)app.GetProfileInt( INI_MINING, INI_CALIBRATION, HEAD_DONT_CALIBRATE ) )
, minedTimingPen( 2, COLOR_RED )
, minedIndexPen( 2, COLOR_BLUE )
, minedTrackDeltaTiming( Utils::MakeCallocPtr<POINT,int>(MINED_TRACK_TIMES_COUNT_MAX) )
, di(
CChartView::TMargin::Default, graphics.list, ARRAYSIZE(graphics.list), Utils::CRideFont::StdBold,
's', INT_MIN, Utils::CTimeline::TimePrefixes,
Expand Down

0 comments on commit 3331fe3

Please sign in to comment.