Opened 18 years ago

Closed 18 years ago

#1744 closed defect (fixed)

msDrawStartShapeUsingIdxSWF needs to check return value from msLayerGetShape

Reported by: bogdan@… Owned by: mapserverbugs
Priority: high Milestone:
Component: Output-SWF Version: 4.8
Severity: normal Keywords:
Cc:

Description

Te follwing  code will crash the applciation because the tile index is not
passed. Moreover, the return code is not checked to see if actually the shape
object was created. As a result in case of failure the next call to
msDrawStartShapeSWF will crash mapserv.

-------------------------------------------------
void msDrawStartShapeUsingIdxSWF(mapObj *map, layerObj *layer, imageObj *image,
                                 int shapeidx)
{
    shapeObj shape;

    if (map && layer && image && shapeidx >=0)
    {
        msInitShape(&shape);
        msLayerGetShape(layer, &shape, -1, shapeidx);
        msDrawStartShapeSWF(map, layer, image, &shape);
    }
}


should be changed to :
======================================

void msDrawStartShapeUsingIdxSWF(mapObj *map, layerObj *layer, imageObj *image,
labelCacheMemberObj * cachePtr)
{
   shapeObj shape;
   int retval = 0;
   if (map && layer && image && cachePtr->shapeindex >=0)
   {
      msInitShape(&shape);
      //retval = msLayerGetShape(layer, &shape, -1, shapeidx);  
	  retval = msLayerGetShape(layer, &shape, cachePtr->tileindex,
cachePtr->shapeindex);
	  
	  if (retval == MS_SUCCESS) {
        msDrawStartShapeSWF(map, layer, image, &shape);
	  } else {
		msSetError(MS_MISCERR, "Cannot find shape for shapeidx:%d", 
"msDrawStartShapeUsingIdxSWF()", cachePtr->shapeindex);
		//writeError();
	  }
   }
}
 
This code was there in 4.2 and it is still there in 4.8

Regards,
Bogdan

Change History (2)

comment:1 by sdlime, 18 years ago

Component: MapServer C LibraryOutput-SWF
Owner: changed from sdlime to mapserverbugs

comment:2 by assefa, 18 years ago

Resolution: fixed
Status: newclosed
changed in mapserver cvs main branch. Will be available for 4.10 release. Thanks
for reproting and the code.
Note: See TracTickets for help on using tickets.