From 3357cc071793c0301fc7c408a3275e510fecf33c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 May 2011 10:16:12 +0000 Subject: [PATCH] Fixed 3 Coverity issues. CID 11697: Uninitialized scalar field (UNINIT_CTOR) Non-static class member _type is not initialized in this constructor nor in any functions that it calls. CID 11698: Uninitialized scalar field (UNINIT_CTOR) Non-static class member _type is not initialized in this constructor nor in any functions that it calls. CID 12329: Resource leak (RESOURCE_LEAK) Calling allocation function "osg::Object::clone(osg::CopyOp const &) const". (The virtual call resolves to "osg::Object * GDALPlugin::DataSetLayer::clone(osg::CopyOp const &) const".) [show details] Failing to save storage allocated by "this->getVertexArray()->clone(struct osg::CopyOp const(128U))" leaks it. --- src/osg/Geometry.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 7e129db8a..213179e04 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -1286,7 +1286,8 @@ class AttributeFunctorArrayVisitor : public ArrayVisitor public: AttributeFunctorArrayVisitor(Drawable::AttributeFunctor& af): - _af(af) {} + _af(af), + _type(0) {} virtual ~AttributeFunctorArrayVisitor() {} @@ -1358,7 +1359,8 @@ class ConstAttributeFunctorArrayVisitor : public ConstArrayVisitor public: ConstAttributeFunctorArrayVisitor(Drawable::ConstAttributeFunctor& af): - _af(af) {} + _af(af), + _type(0) {} virtual ~ConstAttributeFunctorArrayVisitor() {} @@ -2456,7 +2458,7 @@ void Geometry::duplicateSharedArrays() #define DUPLICATE_IF_REQUIRED(A) \ if (get##A() && get##A()->referenceCount()>1) \ { \ - set##A(dynamic_cast(get##A()->clone(osg::CopyOp::DEEP_COPY_ARRAYS))); \ + set##A(osg::clone(get##A(), osg::CopyOp::DEEP_COPY_ARRAYS)); \ } DUPLICATE_IF_REQUIRED(VertexArray) @@ -2469,7 +2471,7 @@ void Geometry::duplicateSharedArrays() { if (getTexCoordArray(ti) && getTexCoordArray(ti)->referenceCount()>1) { - setTexCoordArray(ti, dynamic_cast(getTexCoordArray(ti)->clone(osg::CopyOp::DEEP_COPY_ARRAYS))); + setTexCoordArray(ti, osg::clone(getTexCoordArray(ti),osg::CopyOp::DEEP_COPY_ARRAYS)); } } @@ -2478,7 +2480,7 @@ void Geometry::duplicateSharedArrays() ArrayData& arrayData = _vertexAttribList[vi]; if (arrayData.array.valid() && arrayData.array->referenceCount()>1) { - arrayData.array = dynamic_cast(arrayData.array->clone(osg::CopyOp::DEEP_COPY_ARRAYS)); + arrayData.array = osg::clone(arrayData.array.get(), osg::CopyOp::DEEP_COPY_ARRAYS); } } }