From 07bed106af9a2d77ab36109814f11e94a2b2232e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 6 May 2011 10:27:59 +0000 Subject: [PATCH] Fixed Covertiy reported issues. CID 11394: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::IntArray". Assigning: "this->colorindices" = "new osg::IntArray". The constructor allocates field "colorindices" of "struct vertexInfo" but there is no destructor. CID 11395: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::IntArray". Assigning: "this->coordindices" = "new osg::IntArray". The constructor allocates field "coordindices" of "struct vertexInfo" but there is no destructor. CID 11396: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::IntArray". Assigning: "this->normindices" = "new osg::IntArray". The constructor allocates field "normindices" of "struct vertexInfo" but there is no destructor. CID 11397: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::IntArray". Assigning: "this->txindices" = "new osg::IntArray". The constructor allocates field "txindices" of "struct vertexInfo" but there is no destructor. CID 11398: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::Vec2Array". Assigning: "this->txcoords" = "new osg::Vec2Array". The constructor allocates field "txcoords" of "struct vertexInfo" but there is no destructor. CID 11399: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::Vec3Array". Assigning: "this->norms" = "new osg::Vec3Array". The constructor allocates field "norms" of "struct vertexInfo" but there is no destructor. CID 11400: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::Vec3Array". Assigning: "this->coords" = "new osg::Vec3Array". The constructor allocates field "coords" of "struct vertexInfo" but there is no destructor. CID 11401: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::Vec4Array". Assigning: "this->colors" = "new osg::Vec4Array". The constructor allocates field "colors" of "struct vertexInfo" but there is no destructor. CID 11402: Resource leak in object (CTOR_DTOR_LEAK) Allocating memory by calling "new osg::Vec4Array". Assigning: "this->polycols" = "new osg::Vec4Array". The constructor allocates field "polycols" of "struct vertexInfo" but there is no destructor. --- src/osgPlugins/geo/ReaderWriterGEO.cpp | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp index af7c37882..27d241cb6 100644 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ b/src/osgPlugins/geo/ReaderWriterGEO.cpp @@ -160,16 +160,16 @@ public: cpool=coord_pool; npool=normal_pool; } inline bool hasVertexActions(void) const { return !(BehList.empty()); } - inline osg::Vec4Array *getColors() const { return colors;} - inline osg::Vec3Array *getNorms() const { return norms;} - inline osg::Vec3Array *getCoords() const { return coords;} - inline osg::Vec2Array *getTexCoords() const { return txcoords;} - inline osg::IntArray *getColorIndices() const { return colorindices;} - inline osg::IntArray *getCoordIndices() const { return coordindices;} - inline osg::IntArray *getNormIndices() const { return normindices;} - inline osg::IntArray *getTextureIndices() const { return txindices;} + inline osg::Vec4Array *getColors() const { return colors.get();} + inline osg::Vec3Array *getNorms() const { return norms.get();} + inline osg::Vec3Array *getCoords() const { return coords.get();} + inline osg::Vec2Array *getTexCoords() const { return txcoords.get();} + inline osg::IntArray *getColorIndices() const { return colorindices.get();} + inline osg::IntArray *getCoordIndices() const { return coordindices.get();} + inline osg::IntArray *getNormIndices() const { return normindices.get();} + inline osg::IntArray *getTextureIndices() const { return txindices.get();} void addPolcolour( osg::Vec4 cl) { polycols->push_back(cl);} - osg::Vec4Array *getPolcolours() const { return polycols;} + osg::Vec4Array *getPolcolours() const { return polycols.get();} void addVertexActions(geoBehaviourDrawableCB *gcb) const { // add the actions to callback if ( !(BehList.empty()) ) { for (drBehList::const_iterator rcitr=BehList.begin(); @@ -342,16 +342,16 @@ public: private: const std::vector *cpool; // passed in from the geo file const std::vector *npool; - osg::Vec3Array *norms; - osg::Vec3Array *coords; - osg::Vec2Array *txcoords; - osg::Vec4Array *colors; - osg::IntArray *colorindices; - osg::IntArray *coordindices; - osg::IntArray *normindices; - osg::IntArray *txindices; + osg::ref_ptr norms; + osg::ref_ptr coords; + osg::ref_ptr txcoords; + osg::ref_ptr colors; + osg::ref_ptr colorindices; + osg::ref_ptr coordindices; + osg::ref_ptr normindices; + osg::ref_ptr txindices; drBehList BehList; - Vec4Array *polycols; + osg::ref_ptr polycols; }; class geoInfo { // identifies properties required to make a new Geometry, and holds collection of vertices, indices, etc