Fix stack overflow in LWS loader (#5941)

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
This commit is contained in:
tyler92
2024-12-30 12:15:50 +02:00
committed by GitHub
parent ab5b32ecc7
commit 5e091572d5

View File

@@ -585,6 +585,15 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// and add the file to the import list
SkipSpaces(&c, end);
std::string path = FindLWOFile(c);
if (path.empty()) {
throw DeadlyImportError("LWS: Invalid LoadObjectLayer: empty path.");
}
if (path == pFile) {
throw DeadlyImportError("LWS: Invalid LoadObjectLayer: self reference.");
}
d.path = path;
d.id = batch.AddLoadRequest(path, 0, &props);
@@ -602,6 +611,15 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
d.number = cur_object++;
}
std::string path = FindLWOFile(c);
if (path.empty()) {
throw DeadlyImportError("LWS: Invalid LoadObject: empty path.");
}
if (path == pFile) {
throw DeadlyImportError("LWS: Invalid LoadObject: self reference.");
}
d.id = batch.AddLoadRequest(path, 0, nullptr);
d.path = path;