From 446c7147270ee69148a82d431309fdd3f8b458ce Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 4 Jan 2016 20:39:08 +0100 Subject: [PATCH] Fix a possible memory leak in error case --- apps/openmw/mwrender/npcanimation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4e367b3b18..a032896a71 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -352,13 +352,13 @@ public: virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { osgUtil::CullVisitor* cv = static_cast(nv); - osg::RefMatrix* projectionMatrix = new osg::RefMatrix(*cv->getProjectionMatrix()); float fov, aspect, zNear, zFar; - if (projectionMatrix->getPerspective(fov, aspect, zNear, zFar)) + if (cv->getProjectionMatrix()->getPerspective(fov, aspect, zNear, zFar)) { fov = mFov; - projectionMatrix->makePerspective(fov, aspect, zNear, zFar); - cv->pushProjectionMatrix(projectionMatrix); + osg::RefMatrix* newProjectionMatrix = new osg::RefMatrix(*cv->getProjectionMatrix()); + newProjectionMatrix->makePerspective(fov, aspect, zNear, zFar); + cv->pushProjectionMatrix(newProjectionMatrix); traverse(node, nv); cv->popProjectionMatrix(); }