diff --git a/src/pipeline/wowee_model.cpp b/src/pipeline/wowee_model.cpp index c5cb71ef..b645b3bb 100644 --- a/src/pipeline/wowee_model.cpp +++ b/src/pipeline/wowee_model.cpp @@ -261,9 +261,21 @@ bool WoweeModelLoader::save(const WoweeModel& model, const std::string& basePath f.write(reinterpret_cast(&vertCount), 4); f.write(reinterpret_cast(&indexCount), 4); f.write(reinterpret_cast(&texCount), 4); - f.write(reinterpret_cast(&model.boundRadius), 4); - f.write(reinterpret_cast(&model.boundMin), 12); - f.write(reinterpret_cast(&model.boundMax), 12); + // Sanitize bound floats at save time; matches the load-time guard so a + // partial-write or in-memory corruption can't poison the file. + float boundRadius = std::isfinite(model.boundRadius) && model.boundRadius >= 0.0f + ? model.boundRadius : 1.0f; + glm::vec3 boundMin = model.boundMin, boundMax = model.boundMax; + auto sanVec3 = [](glm::vec3& v) { + if (!std::isfinite(v.x)) v.x = 0.0f; + if (!std::isfinite(v.y)) v.y = 0.0f; + if (!std::isfinite(v.z)) v.z = 0.0f; + }; + sanVec3(boundMin); + sanVec3(boundMax); + f.write(reinterpret_cast(&boundRadius), 4); + f.write(reinterpret_cast(&boundMin), 12); + f.write(reinterpret_cast(&boundMax), 12); // Same writeStr pattern as WoB: truncate to 1KB so the u16 length doesn't // wrap and corrupt the rest of the file.