From fa3b27d79918c7b0b72dcb148297b81faa2d2443 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 24 Mar 2025 15:16:54 +0100 Subject: [PATCH] SPE-2725: Fix crash when loading invalid STL (#14343) --- bundled_deps/admesh/admesh/stlinit.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bundled_deps/admesh/admesh/stlinit.cpp b/bundled_deps/admesh/admesh/stlinit.cpp index 3e1886bf64..f2a518486f 100644 --- a/bundled_deps/admesh/admesh/stlinit.cpp +++ b/bundled_deps/admesh/admesh/stlinit.cpp @@ -222,6 +222,15 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first) } #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. stl->facet_start[i] = facet; stl_facet_stats(stl, facet, first);