msSHPReadShape and potential memory leak (and sorthshp.c)

Richard Roger richard.roger at AGRIC.NSW.GOV.AU
Tue Jul 12 01:47:04 EDT 2005


Thanks, Frank

I thought this might be the problem as I've encountered uninitialized 
pointers with non-null values before. 

Should I file an enhancement via bugzilla for sorthshp.c to add a call to 
msFreeShape ?  I'm sorry but I'm not sure of correct protocol here.

And this is at the top of the post as it's difficult to bottom post using 
our Lotus Notes system...

Cheers

Richard

Dr. R. E. Roger                             NSW Department of 
                                         Primary Industries
Spatial Information Officer Systems                    161 Kite St
Resource Information Unit                     Locked Bag 21
                                           ORANGE NSW 2800
ph: (02) 6391 3697                               fax: (02) 6391 3740




Frank Warmerdam <fwarmerdam at gmail.com>
12/07/2005 12:45 AM
Please respond to warmerdam

 
        To:     richard.roger at agric.nsw.gov.au
        cc:     MAPSERVER-DEV at lists.umn.edu
        Subject:        Re: [UMN_MAPSERVER-DEV] msSHPReadShape and potential memory leak (and 
sorthshp.c)


On 7/10/05, Richard Roger <richard.roger at agric.nsw.gov.au> wrote:

> This memory "leak" in the first loop is caused by my initially poor
> understanding and use of msSHPReadShape, but I think it's a mistake 
others
> might easily make.  I think this "feature" could be avoided by the 
following
> change : 
> 
> *** replace the call to "msInitShape" in "msSHPReadShape" by a call to a
> "msFreeShape". 
> 
> I am not sure if "msFreeShape" would need to be modified to deal with an
> entirely null shape. 

Richard, 

The problem is that msSHPReadShape() is typically used with shapeObj's
allocated on the stack, but these are not initialized to any dependable
value.  So msSHPReadShape() has no way of telling if the shapeObj
fields have pointers that need to be freed, or are just unitialized
values pointing into hyperspace. 

So, I don't really think there is much we can practically do to change
things ... we just need to be careful.

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





This message is intended for the addressee named and may contain 
confidential information. If you are not the intended recipient or 
received it in error, please delete the message and notify sender. Views 
expressed are those of the individual sender and are not necessarily the 
views of their organisation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20050712/94acd815/attachment.html


More information about the mapserver-dev mailing list