Update metadata.h

Fix possible crashes.
pull/2810/head
Kim Kulling 2019-12-06 21:24:04 +01:00 committed by GitHub
parent b2ab3fa35e
commit c1706d9bf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -380,11 +380,14 @@ struct aiMetadata {
/// Check whether there is a metadata entry for the given key.
/// \param [in] Key - the key value value to check for.
inline
bool HasKey(const char* key)
{
bool HasKey(const char* key) {
if ( nullptr == key ) {
return false;
}
// Search for the given key
for (unsigned int i = 0; i < mNumProperties; ++i) {
if (strcmp(mKeys[i].C_Str(), key) == 0) {
if ( 0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length ) ) {
return true;
}
}