This project has moved and is read-only. For the latest updates, please go here.

Possible Bug in getPolyRings function in ShapeFileProvider.cs

Topics: SharpMap v2.0
Jul 26, 2008 at 7:50 PM

I have tried to open a number of shapefiles and I get an exception thrown when trying to open the file. I have traced the exception to the getPolyRings function in ShapeFileProvider.cs. In the file I tried to read, the ref parameter i on entry was 16 and rings.count = 17. The line singlePoly.Add(rings[i++]) increments i after use to 17 and then tries to check the value of isCounterClockWise[17]. This results in an out of bounds exception as the array size is 17. I repeated for other shapefiles and got exceptions thrown at the same line.

Could some confirm if this is a bug and if so when a patch would be posted.


        private static List<ILinearRing> getPolyRings(IList<ILinearRing> rings, Boolean[] isCounterClockWise, ref Int32 i)
            List<ILinearRing> singlePoly = new List<ILinearRing>();
           // make sure the first ring is an exterior ring
            Debug.Assert(isCounterClockWise[i] == false);
            while (isCounterClockWise[i])
            return singlePoly;