Fixed potential memory leak

This commit is contained in:
Robert Osfield 2016-06-02 15:43:31 +01:00
parent f10e931f82
commit 4d2221bdb3

View File

@ -86,9 +86,6 @@ public:
Point* computeInterpolatedPoint(Edge* edge,float r) const Point* computeInterpolatedPoint(Edge* edge,float r) const
{ {
Point* point = new Point;
float r1 = 1.0f-r;
float r2 = r;
Point* p1 = edge->_p1.get(); Point* p1 = edge->_p1.get();
Point* p2 = edge->_p2.get(); Point* p2 = edge->_p2.get();
@ -98,6 +95,10 @@ public:
return 0; return 0;
} }
Point* point = new Point;
float r1 = 1.0f-r;
float r2 = r;
point->_vertex = p1->_vertex * r1 + p2->_vertex * r2; point->_vertex = p1->_vertex * r1 + p2->_vertex * r2;
unsigned int s = osg::minimum(p1->_attributes.size(),p2->_attributes.size()); unsigned int s = osg::minimum(p1->_attributes.size(),p2->_attributes.size());
for(unsigned int i=0;i<s;++i) for(unsigned int i=0;i<s;++i)
@ -1753,7 +1754,7 @@ void Simplifier::simplify(osg::Geometry& geometry, const IndexList& protectedPoi
unsigned int numOriginalPrimitives = ec._triangleSet.size(); unsigned int numOriginalPrimitives = ec._triangleSet.size();
if (downSample) if (downSample)
{ {
while (!ec._edgeSet.empty() && while (!ec._edgeSet.empty() &&