From 0ff04b97695b03c0824750b0c69c44057685e93a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 13 Dec 2019 11:20:50 +0100 Subject: [PATCH] Update ColladaParser.cpp Fix the build and fix 2 possible nullptr dereferences. --- code/Collada/ColladaParser.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/Collada/ColladaParser.cpp b/code/Collada/ColladaParser.cpp index 1577c794a..df5a95c5b 100644 --- a/code/Collada/ColladaParser.cpp +++ b/code/Collada/ColladaParser.cpp @@ -250,6 +250,9 @@ void ColladaParser::UriDecodePath(aiString& ss) bool ColladaParser::ReadBoolFromTextContent() { const char* cur = GetTextContent(); + if ( nullptr == cur) { + return false; + } return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur); } @@ -258,6 +261,9 @@ bool ColladaParser::ReadBoolFromTextContent() ai_real ColladaParser::ReadFloatFromTextContent() { const char* cur = GetTextContent(); + if ( nullptr == cur ) { + return 0.0; + } return fast_atof(cur); } @@ -278,7 +284,9 @@ void ColladaParser::ReadContents() const char* version = mReader->getAttributeValue(attrib); // Store declared format version string - mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, version); + aiString v; + v.Set(version); + mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v ); if (!::strncmp(version, "1.5", 3)) { mFormat = FV_1_5_n;