bug in msquery.c msQueryByShape()

Phill W phill.watson at SCISYS.CO.UK
Mon May 16 10:18:11 EDT 2005


Hi,

First of all. Thanks to all for the effort put into MapServer.

I've been attempting to get "imgshape" nquery working with PostGIS tables
and come across a bug I thought I would share with whoever's listening. I
wasn't sure where to post this, so here it is.

The bug definitely affects postGIS layers, but may affect others.

Within the function msQueryByShape() a local shapeObj is used to iterate
the results of the search. This should be initialised (cleared) before the
loop. The postGis driver calls msAddLine during its processing of
msLayerNextShape(), and this attempts to free the reference pointed to be
shape->line.

The snippet of msQueryByShape() to change below:

  lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); //
allocate and initialize the result cache
  lp->resultcache->results = NULL;
  lp->resultcache->numresults = lp->resultcache->cachesize = 0;
  lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp-
>resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;

  msInitShape(&shape); // initialise shape object
  while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { // step
through the shapes
    shape.classindex = msShapeGetClass(lp, &shape, map->scale);


Thanks again,
Phill



More information about the mapserver-users mailing list