Bug report #6170

Heap corruption in PAL

Added by Matthias Kuhn almost 12 years ago. Updated almost 12 years ago.

Assignee:Matthias Kuhn
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:15488


My debugger (VS2008) was complaining about a heap corruption. After some investigation I could locate the following:

double dist8;

costcalculator.cpp, line 275 (in void PolygonCostCalculator::updatePoint( PointSet *pset )):

int i = ( int )( beta / a45 );

dist[i] = d;

Guess what happens if i == 8
Probably nothing unless you happen to have something important after the dist array.

Now you might wonder, how comes, that i is 8. I've no idea why, but I guess that following pure math it shouldn't.

Back to line 275
i = beta / a45

In my case beta = 6.2831853071795862 and a45 = 0.78539816339744828
My windows calc shows me as the result 7.9999999999999999490704182105935 which should be rounded to 7. But my debugger shows me 8.

I don't whose fault it is that windows calculator gives another result than dividing two doubles does, but there seems to be something wrong.

Associated revisions


#1 Updated by Jürgen Fischer almost 12 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF