Fix possible nullptr dereferencing in material parsing

* Return 0.0f for empty buffer
* closes https://github.com/assimp/assimp/issues/3442
pull/4085/head
Kim Kulling 2021-09-21 11:06:18 +02:00 committed by GitHub
parent 4fd7330808
commit fb5b5e9d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -232,6 +232,12 @@ void ObjFileMtlImporter::getIlluminationModel(int &illum_model) {
// Loads a single float value.
void ObjFileMtlImporter::getFloatValue(ai_real &value) {
m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
size_t len = std::strlen(&m_buffer[0]);
if (0 == len) {
value = 0.0f;
return;
}
value = (ai_real)fast_atof(&m_buffer[0]);
}