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 "<storage from new>" 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 "<storage from new>" is not freed or pointed-to in function "osg::ElementBufferObject::ElementBufferObject()". [show details]
Assigning: "ebo" = storage returned from "new osg::ElementBufferObject".
This commit is contained in:
Robert Osfield
2011-04-27 16:01:43 +00:00
parent 9a4c277592
commit 501008f256

View File

@@ -796,7 +796,7 @@ void Geometry::setUseVertexBufferObjects(bool flag)
VertexBufferObjectList vboList;
osg::VertexBufferObject* vbo = 0;
osg::ref_ptr<osg::VertexBufferObject> 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<osg::ElementBufferObject> 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());
}
}
}