I found a couple of memory leaks in 3DS reader plugin and I have attached 
corrected files. I have attached an example 3DS file I used to test the 
leaks/fixes using osgviewer for trunk at rev [14853] and the tagged version 
3.2.1. 

The first leak is in the lib3ds module (yeah, I know that probably should be 
corrected at http://code.google.com/p/lib3ds/ but I'm assuming that as no 
commits have happened there since 2011 that it may be better to fix the copy we 
have in the OSG of that project) The leak is caused by lib3d's use of 
realloc(ptr, 0) to free up memory allocations, but realloc, when ptr==NULL 
returns malloc(0) rather than NULL and thus leaks a zero byte allocation. The 
solution here was to adjust the 'lib3ds_util_reserve_array' function so that it 
realloc is not used to release a NULL pointer.

The second leak is in ReaderWriter3DS.cpp and arises when any of the created 
StateSet objects added to the StateSetMap don't subsequently get applied to a 
Node. The solution here was just to simply use the osg::ref_ptr around the raw 
StateSet pointer that was used in the locally defined StateSetInfo struct.

Chris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63494#63494




Attachments: 
http://forum.openscenegraph.org//files/fixleak3ds_159.zip


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to