SPE-2725: Fix crash when loading invalid STL (#14343)

This commit is contained in:
Lukas Matena 2025-03-24 15:16:54 +01:00
parent ed7b612753
commit fa3b27d799

View File

@ -222,6 +222,15 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first)
} }
#endif #endif
for (int j = 0; j < 3; ++j) {
for (int u = 0; u < 3; ++u) {
if (std::isnan(facet.vertex[j](u)) || std::isinf(facet.vertex[j](u))) {
BOOST_LOG_TRIVIAL(error) << "stl_read: facet " << i << ": vertex " << j << "contains invalid coordinate";
return false;
}
}
}
// Write the facet into memory. // Write the facet into memory.
stl->facet_start[i] = facet; stl->facet_start[i] = facet;
stl_facet_stats(stl, facet, first); stl_facet_stats(stl, facet, first);