[Shapelib] Delete or hide Shape from Shapefile

Frank Warmerdam warmerdam at pobox.com
Tue May 19 08:49:07 EST 2009


Jelmer Baas wrote:
> The following code freezes my application:
> 
>     Dim intShapeFile As Integer, intEntities As Integer, objShapeType As
> MapTools.ShapeLib.ShapeType
>     Dim minB(2) As Double, maxB(2) As Double
> 
>     intShapeFile = SHPOpen("C:\test\test.shp", "rb+")
>     SHPGetInfo(intShapeFile, intEntities, objShapeType, minB, maxB)
>     SHPClose(intShapeFile)
>     System.GC.Collect()
> 
> I tried a different shape file, same problem. MapServer can properly
> draw the shapes, so 
> I think it's a valid file, too. There's no way to recover except kill
> the application.
> 
> 
> Well, wouldn't you know. While typing this I had another idea: to skip
> SHPGetInfo, and that 
> does the trick. Question remains: why does SHPGetInfo crash the app when
> using Shapelib?

Jelmer,

The minB, maxB arguments to SHPGetInfo() should be dimensioned with a size
of four (X, Y, Z, measure), not 2.  I presume SHPGetInfo is writing past
the end of your arrays and corrupting the heap.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Shapelib mailing list