Bug report #6170

Heap corruption in PAL

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

Status:Closed
Priority:Normal
Assignee:Matthias Kuhn
Category:-
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

Description

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

costcalculator.h:
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

History

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

  • Status changed from Open to Closed

Also available in: Atom PDF