Merge pull request #4282 from assimp/kimkulling-fix_heap_overflow_during_utf8_issue4230
Make sure no overflow can happenpull/4283/head
commit
7ec52e9e02
|
@ -65,6 +65,7 @@ using namespace Assimp;
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseImporter::BaseImporter() AI_NO_EXCEPT
|
BaseImporter::BaseImporter() AI_NO_EXCEPT
|
||||||
: m_progress() {
|
: m_progress() {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -372,7 +373,10 @@ void BaseImporter::ConvertToUTF8(std::vector<char> &data) {
|
||||||
|
|
||||||
// UTF 16 BE with BOM
|
// UTF 16 BE with BOM
|
||||||
if (*((uint16_t *)&data.front()) == 0xFFFE) {
|
if (*((uint16_t *)&data.front()) == 0xFFFE) {
|
||||||
|
// Check to ensure no overflow can happen
|
||||||
|
if(data.size() % 2 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// swap the endianness ..
|
// swap the endianness ..
|
||||||
for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) {
|
for (uint16_t *p = (uint16_t *)&data.front(), *end = (uint16_t *)&data.back(); p <= end; ++p) {
|
||||||
ByteSwap::Swap2(p);
|
ByteSwap::Swap2(p);
|
||||||
|
|
Loading…
Reference in New Issue