From 6549dc8a7e2543d8adeb05602d656827b6147d64 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 6 Jul 2014 04:38:15 +0200 Subject: [PATCH 1/3] fix memory leak Found by Lsan. Upstreamed Libreoffice patch. --- converter/COLLADA2GLTF/shaders/commonProfileShaders.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/converter/COLLADA2GLTF/shaders/commonProfileShaders.cpp b/converter/COLLADA2GLTF/shaders/commonProfileShaders.cpp index bbf67faca5..cbc416e2b6 100644 --- a/converter/COLLADA2GLTF/shaders/commonProfileShaders.cpp +++ b/converter/COLLADA2GLTF/shaders/commonProfileShaders.cpp @@ -514,6 +514,10 @@ namespace GLTF this->_profile = profile; this->_instanceProgram = new GLSLProgram(profile); } + + ~Pass() { + delete _instanceProgram; + } GLSLProgram* instanceProgram() { return this->_instanceProgram; @@ -1207,6 +1211,10 @@ namespace GLTF vertexShader->appendCode("}\n"); fragmentShader->appendCode("}\n"); } + + ~Technique() { + delete _pass; + } shared_ptr parameters() { return _parameters; From 1f58e0826a6196627a73011e53255e18a666b118 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 6 Jul 2014 07:07:20 +0200 Subject: [PATCH 2/3] fix indentation --- converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp b/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp index a3dfb4cdf3..0ee8438014 100644 --- a/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp +++ b/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp @@ -74,10 +74,10 @@ namespace GLTF asset->setExtras(this->_extraDataHandler->allExtras()); asset->prepareForProfile(shared_ptr (new GLTFWebGL_1_0_Profile())); - COLLADAFW::Root root(&this->_loader, this); + COLLADAFW::Root root(&this->_loader, this); this->_loader.registerExtraDataCallbackHandler(this->_extraDataHandler); - if (!root.loadDocument(asset->getInputFilePath())) - return false; + if (!root.loadDocument(asset->getInputFilePath())) + return false; asset->write(); @@ -85,7 +85,7 @@ namespace GLTF GLTFUtils::resetIDCount(); clearCommonProfileTechniqueCache(); - return true; + return true; } //-------------------------------------------------------------------- From 5f7920f7ee4d16c67d5c84a9796e672eb6d99615 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 6 Jul 2014 07:09:34 +0200 Subject: [PATCH 3/3] fix memory leak Found by Lsan. Upstreamed Libreoffice patch. --- converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp b/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp index 0ee8438014..485680d508 100644 --- a/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp +++ b/converter/COLLADA2GLTF/COLLADA2GLTFWriter.cpp @@ -76,8 +76,10 @@ namespace GLTF COLLADAFW::Root root(&this->_loader, this); this->_loader.registerExtraDataCallbackHandler(this->_extraDataHandler); - if (!root.loadDocument(asset->getInputFilePath())) + if (!root.loadDocument(asset->getInputFilePath())) { + delete _extraDataHandler; return false; + } asset->write(); @@ -85,6 +87,7 @@ namespace GLTF GLTFUtils::resetIDCount(); clearCommonProfileTechniqueCache(); + delete _extraDataHandler; return true; }