OpenDDLParser: Fix potential memory leak

pull/1498/head
Turo Lamminen 2017-11-15 11:58:13 +02:00
parent 9dadec7736
commit eb5f47f5c5
1 changed files with 4 additions and 3 deletions

View File

@ -27,6 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <memory>
#include <math.h> #include <math.h>
#ifdef _WIN32 #ifdef _WIN32
@ -275,12 +276,12 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
} }
delete id; delete id;
Name *name(ddl_nullptr); Name *name_(ddl_nullptr);
in = OpenDDLParser::parseName(in, end, &name); in = OpenDDLParser::parseName(in, end, &name_);
std::unique_ptr<Name> name(name_);
if( ddl_nullptr != name && ddl_nullptr != node ) { if( ddl_nullptr != name && ddl_nullptr != node ) {
const std::string nodeName( name->m_id->m_buffer ); const std::string nodeName( name->m_id->m_buffer );
node->setName( nodeName ); node->setName( nodeName );
delete name;
} }