[ion] Storage: fix crash due to wrong assertion

Python tries to import files without extension, it should not crash but
return an empty Record.
This commit is contained in:
Émilie Feral
2019-09-02 10:30:54 +02:00
parent 62793f41e0
commit 77304040ad

View File

@@ -43,8 +43,11 @@ Storage::Record::Record(const char * fullName) {
return;
}
const char * dotChar = UTF8Helper::CodePointSearch(fullName, k_dotChar);
assert(*dotChar != 0);
assert(*(dotChar+1) != 0); // Assert there is an extension
// If no extension, return empty record
if (*dotChar == 0 || *(dotChar+1) == 0) {
m_fullNameCRC32 = 0;
return;
}
new (this) Record(fullName, dotChar - fullName, dotChar+1, (fullName + strlen(fullName)) - (dotChar+1));
}