Merge branch 'master' into MalcolmTyrrell/jsonSchemaSupport
This commit is contained in:
@@ -149,7 +149,7 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) :
|
||||
|
||||
IOStream *fileStream = mZipArchive->Open(file.c_str());
|
||||
if (nullptr == fileStream) {
|
||||
ai_assert(fileStream != nullptr);
|
||||
ASSIMP_LOG_ERROR("Filestream is nullptr.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szC
|
||||
|
||||
// now we need to skip any other skins ...
|
||||
for (unsigned int i = 1; i < iNumSkins; ++i) {
|
||||
SizeCheck(szCursor + 3 * sizeof(uint32_t));
|
||||
iType = *((uint32_t *)szCursor);
|
||||
szCursor += sizeof(uint32_t);
|
||||
iWidth = *((uint32_t *)szCursor);
|
||||
|
||||
@@ -896,7 +896,7 @@ char *_m3d_safestr(char *in, int morelines) {
|
||||
if (!out) return NULL;
|
||||
while (*i == ' ' || *i == '\t' || *i == '\r' || (morelines && *i == '\n'))
|
||||
i++;
|
||||
for (; *i && (morelines || (*i != '\r' && *i != '\n')); i++) {
|
||||
for (; *i && (morelines || (*i != '\r' && *i != '\n')) && o - out < l; i++) {
|
||||
if (*i == '\r') continue;
|
||||
if (*i == '\n') {
|
||||
if (morelines >= 3 && o > out && *(o - 1) == '\n') break;
|
||||
|
||||
@@ -600,7 +600,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345() {
|
||||
|
||||
// need to read all textures
|
||||
for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins; ++i) {
|
||||
if (szCurrent >= szEnd) {
|
||||
if (szCurrent + sizeof(uint32_t) > szEnd) {
|
||||
throw DeadlyImportError("Texture data past end of file.");
|
||||
}
|
||||
BE_NCONST MDL::Skin *pcSkin;
|
||||
|
||||
@@ -132,6 +132,9 @@ void MDLImporter::CreateTextureARGB8_3DGS_MDL3(const unsigned char *szData) {
|
||||
pcNew->mWidth = pcHeader->skinwidth;
|
||||
pcNew->mHeight = pcHeader->skinheight;
|
||||
|
||||
if(pcNew->mWidth != 0 && pcNew->mHeight > UINT_MAX/pcNew->mWidth) {
|
||||
throw DeadlyImportError("Invalid MDL file. A texture is too big.");
|
||||
}
|
||||
pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight];
|
||||
|
||||
const unsigned char *szColorMap;
|
||||
@@ -217,6 +220,9 @@ void MDLImporter::ParseTextureColorData(const unsigned char *szData,
|
||||
|
||||
// allocate storage for the texture image
|
||||
if (do_read) {
|
||||
if(pcNew->mWidth != 0 && pcNew->mHeight > UINT_MAX/pcNew->mWidth) {
|
||||
throw DeadlyImportError("Invalid MDL file. A texture is too big.");
|
||||
}
|
||||
pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight];
|
||||
}
|
||||
|
||||
|
||||
@@ -300,13 +300,14 @@ private:
|
||||
|
||||
const char separator = getOsSeparator();
|
||||
for (it = in.begin(); it != in.end(); ++it) {
|
||||
int remaining = std::distance(in.end(), it);
|
||||
// Exclude :// and \\, which remain untouched.
|
||||
// https://sourceforge.net/tracker/?func=detail&aid=3031725&group_id=226462&atid=1067632
|
||||
if ( !strncmp(&*it, "://", 3 )) {
|
||||
if (remaining >= 3 && !strncmp(&*it, "://", 3 )) {
|
||||
it += 3;
|
||||
continue;
|
||||
}
|
||||
if (it == in.begin() && !strncmp(&*it, "\\\\", 2)) {
|
||||
if (it == in.begin() && remaining >= 2 && !strncmp(&*it, "\\\\", 2)) {
|
||||
it += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -64,20 +64,28 @@ void CommentRemover::RemoveLineComments(const char* szComment,
|
||||
if (len > lenBuffer) {
|
||||
len = lenBuffer;
|
||||
}
|
||||
while (*szBuffer) {
|
||||
|
||||
char *szCurrent = szBuffer;
|
||||
while (*szCurrent) {
|
||||
|
||||
// skip over quotes
|
||||
if (*szBuffer == '\"' || *szBuffer == '\'')
|
||||
while (*szBuffer++ && *szBuffer != '\"' && *szBuffer != '\'');
|
||||
if (!strncmp(szBuffer,szComment,len)) {
|
||||
while (!IsLineEnd(*szBuffer))
|
||||
*szBuffer++ = chReplacement;
|
||||
if (*szCurrent == '\"' || *szCurrent == '\'')
|
||||
while (*szCurrent++ && *szCurrent != '\"' && *szCurrent != '\'');
|
||||
|
||||
if (!*szBuffer) {
|
||||
size_t lenRemaining = lenBuffer - (szCurrent - szBuffer);
|
||||
if(lenRemaining < len) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strncmp(szCurrent,szComment,len)) {
|
||||
while (!IsLineEnd(*szCurrent))
|
||||
*szCurrent++ = chReplacement;
|
||||
|
||||
if (!*szCurrent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++szBuffer;
|
||||
++szCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user