From 501008f256fc0f27db00fca81e85cf12e7418adb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 27 Apr 2011 16:01:43 +0000 Subject: [PATCH] Fixed 2 Coverity reported issues. Following are both false positives as the the scope they are in will always assign the object to a ref counted structure. I've modified the code to use ref_ptr<> to just make it clear that it's underscope, although this is not strictly neccessary as the code is OK, I introduced this for clarity and robustness in presence of exceptions. CID 11586: Resource leak (RESOURCE_LEAK) Calling allocation function "operator new(unsigned long long)". Variable "" is not freed or pointed-to in function "osg::VertexBufferObject::VertexBufferObject()". [show details] Assigning: "vbo" = storage returned from "new osg::VertexBufferObject". CID 11587: Resource leak (RESOURCE_LEAK) Calling allocation function "operator new(unsigned long long)". Variable "" is not freed or pointed-to in function "osg::ElementBufferObject::ElementBufferObject()". [show details] Assigning: "ebo" = storage returned from "new osg::ElementBufferObject". --- src/osg/Geometry.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index f16f20343..7e129db8a 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -796,7 +796,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) VertexBufferObjectList vboList; - osg::VertexBufferObject* vbo = 0; + osg::ref_ptr vbo; ArrayList::iterator vitr; for(vitr = arrayList.begin(); @@ -814,7 +814,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) ++vitr) { osg::Array* array = *vitr; - if (!array->getVertexBufferObject()) array->setVertexBufferObject(vbo); + if (!array->getVertexBufferObject()) array->setVertexBufferObject(vbo.get()); } } @@ -822,7 +822,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) { ElementBufferObjectList eboList; - osg::ElementBufferObject* ebo = 0; + osg::ref_ptr ebo; DrawElementsList::iterator deitr; for(deitr = drawElementsList.begin(); @@ -840,7 +840,7 @@ void Geometry::setUseVertexBufferObjects(bool flag) ++deitr) { osg::DrawElements* elements = *deitr; - if (!elements->getElementBufferObject()) elements->setElementBufferObject(ebo); + if (!elements->getElementBufferObject()) elements->setElementBufferObject(ebo.get()); } } }