From 0a3384de64394c79c6104a16792567521caf58a4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Mar 2004 18:35:06 +0000 Subject: [PATCH] From Paul Martz/Robert Osfield. Addition of initializers in AttrData to prevent bugs due to uninitialized memory references. --- src/osgPlugins/flt/AttrData.h | 25 +++++++++++++++++++++++-- src/osgPlugins/flt/GeoSetBuilder.cpp | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/flt/AttrData.h b/src/osgPlugins/flt/AttrData.h index a14ec894f..39a01fc99 100644 --- a/src/osgPlugins/flt/AttrData.h +++ b/src/osgPlugins/flt/AttrData.h @@ -39,8 +39,29 @@ namespace flt { int32 txDetail_n; // N argument for TX_DETAIL int32 txDetail_s; // Scramble argument for TX_DETAIL bool modulateDetail; // True if Magnification filter type is MODULATE_DETAIL - AttrData() {}; - AttrData(const AttrData& attr,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):osg::Object(attr,copyop) {}; + + AttrData() : + stateset(0), + useDetail(0), + txDetail_j(0), + txDetail_k(0), + txDetail_m(0), + txDetail_n(0), + txDetail_s(0), + modulateDetail(false) {} + + + AttrData(const AttrData& attr,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): + osg::Object(attr,copyop), + stateset(attr.stateset), + useDetail(attr.useDetail), + txDetail_j(attr.txDetail_j), + txDetail_k(attr.txDetail_k), + txDetail_m(attr.txDetail_m), + txDetail_n(attr.txDetail_n), + txDetail_s(attr.txDetail_s), + modulateDetail(attr.modulateDetail) {} + virtual osg::Object* cloneType() const { return new AttrData(); } virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AttrData(*this,copyop); } virtual const char* libraryName() const { return "osg"; } diff --git a/src/osgPlugins/flt/GeoSetBuilder.cpp b/src/osgPlugins/flt/GeoSetBuilder.cpp index 95bc92477..f2ca3644e 100644 --- a/src/osgPlugins/flt/GeoSetBuilder.cpp +++ b/src/osgPlugins/flt/GeoSetBuilder.cpp @@ -174,7 +174,7 @@ void DynGeoSet::addToGeometry(osg::Geometry* geom) // // Julian Ortiz, June 18th 2003. - if (_attrdata != NULL ) { + if ( (_attrdata != NULL) && (_attrdata->useDetail > 0) ) { osg::Vec2Array *texcoords2 = new osg::Vec2Array(_tcoordList.begin(),_tcoordList.end()); for(unsigned int index=0;indexsize();index++) { (*texcoords2)[index][0]=(*texcoords)[index][0]*_attrdata->txDetail_m;