Skip to content

Commit 437b484

Browse files
authored
Fix heap buffer overflow in HMP loader (assimp#5939)
1 parent d70606b commit 437b484

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

code/AssetLib/HMP/HMPLoader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,14 @@ void HMPImporter::ValidateHeader_HMP457() {
163163
"120 bytes, this file is smaller)");
164164
}
165165

166+
if (!std::isfinite(pcHeader->ftrisize_x) || !std::isfinite(pcHeader->ftrisize_y))
167+
throw DeadlyImportError("Size of triangles in either x or y direction is not finite");
168+
166169
if (!pcHeader->ftrisize_x || !pcHeader->ftrisize_y)
167-
throw DeadlyImportError("Size of triangles in either x or y direction is zero");
170+
throw DeadlyImportError("Size of triangles in either x or y direction is zero");
171+
172+
if (!std::isfinite(pcHeader->fnumverts_x))
173+
throw DeadlyImportError("Number of triangles in x direction is not finite");
168174

169175
if (pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts / pcHeader->fnumverts_x) < 1.0f)
170176
throw DeadlyImportError("Number of triangles in either x or y direction is zero");

0 commit comments

Comments
 (0)