Crash bug - with fix

Ned Harding nharding at EXTENDTHEREACH.COM
Thu Sep 15 16:06:11 EDT 2005


freeFeatureList (mapfile.c) frees a list recursively, so if you have a lot
of things on the list it causes a stack fault.  This happens (on my machine)
with a line layer with overlays with about 4000 objects.  It should be
changed to free in a loop so that it doesn't blow out the stack.  The old
code and new fixed code is below.  Can someone review it and check it in to
CVS for me?  Note my loop does change the order of freeing from last->first
to first->last.  It doesn't appear to matter in this situation.

// old code
void freeFeatureList(featureListNodeObjPtr list)
{
  if(list) {
    freeFeatureList(list->next); /* free any children */
    msFreeShape(&(list->shape));
    msFree(list);
  }
  return;
}

// new fixed code
void freeFeatureList(featureListNodeObjPtr list)
{
	featureListNodeObjPtr listNext = NULL;
	while (list!=NULL)
	{
		listNext = list->next;
		msFreeShape(&(list->shape));
		msFree(list);
		list = listNext;
	}
} 

Thanks,
 
Ned Harding
Chief Technology Officer
SRC - Extending the Reach of Micromarketing
3825 Iris Ave Suite 150
Boulder, CO 80303
(303) 440-8896 x104

http://www.extendthereach.com <http://www.extendthereach.com/> 

Technology in Action:

http://www.DemographicsNow.com <http://www.demographicsnow.com/> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20050915/2a7480c3/attachment.html


More information about the mapserver-dev mailing list