summaryrefslogtreecommitdiffstats
path: root/code/AssetLib/HMP/HMPLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'code/AssetLib/HMP/HMPLoader.cpp')
-rw-r--r--code/AssetLib/HMP/HMPLoader.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp
index 30931a920..26558edab 100644
--- a/code/AssetLib/HMP/HMPLoader.cpp
+++ b/code/AssetLib/HMP/HMPLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2024, assimp team
+Copyright (c) 2006-2025, assimp team
All rights reserved.
@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
// internal headers
-#include "AssetLib/HMP/HMPLoader.h"
+#include "HMPLoader.h"
#include "AssetLib/MD2/MD2FileData.h"
#include <assimp/StringUtils.h>
@@ -81,7 +81,7 @@ HMPImporter::~HMPImporter() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool HMPImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
- static const uint32_t tokens[] = {
+ static constexpr uint32_t tokens[] = {
AI_HMP_MAGIC_NUMBER_LE_4,
AI_HMP_MAGIC_NUMBER_LE_5,
AI_HMP_MAGIC_NUMBER_LE_7
@@ -163,8 +163,14 @@ void HMPImporter::ValidateHeader_HMP457() {
"120 bytes, this file is smaller)");
}
+ if (!std::isfinite(pcHeader->ftrisize_x) || !std::isfinite(pcHeader->ftrisize_y))
+ throw DeadlyImportError("Size of triangles in either x or y direction is not finite");
+
if (!pcHeader->ftrisize_x || !pcHeader->ftrisize_y)
- throw DeadlyImportError("Size of triangles in either x or y direction is zero");
+ throw DeadlyImportError("Size of triangles in either x or y direction is zero");
+
+ if (!std::isfinite(pcHeader->fnumverts_x))
+ throw DeadlyImportError("Number of triangles in x direction is not finite");
if (pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts / pcHeader->fnumverts_x) < 1.0f)
throw DeadlyImportError("Number of triangles in either x or y direction is zero");