Update ColladaParser.cpp

Fix the build and fix 2 possible nullptr dereferences.
pull/2820/head
Kim Kulling 2019-12-13 11:20:50 +01:00 committed by GitHub
parent 53bf442beb
commit 0ff04b9769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -250,6 +250,9 @@ void ColladaParser::UriDecodePath(aiString& ss)
bool ColladaParser::ReadBoolFromTextContent() bool ColladaParser::ReadBoolFromTextContent()
{ {
const char* cur = GetTextContent(); const char* cur = GetTextContent();
if ( nullptr == cur) {
return false;
}
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur); return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
} }
@ -258,6 +261,9 @@ bool ColladaParser::ReadBoolFromTextContent()
ai_real ColladaParser::ReadFloatFromTextContent() ai_real ColladaParser::ReadFloatFromTextContent()
{ {
const char* cur = GetTextContent(); const char* cur = GetTextContent();
if ( nullptr == cur ) {
return 0.0;
}
return fast_atof(cur); return fast_atof(cur);
} }
@ -278,7 +284,9 @@ void ColladaParser::ReadContents()
const char* version = mReader->getAttributeValue(attrib); const char* version = mReader->getAttributeValue(attrib);
// Store declared format version string // 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)) { if (!::strncmp(version, "1.5", 3)) {
mFormat = FV_1_5_n; mFormat = FV_1_5_n;