mat3x3: check for finite in toString (#70)

if values are NaN or inf it will crash std::format, safeguard it.
This commit is contained in:
Tom Englund 2025-07-23 12:14:37 +02:00 committed by GitHub
parent 18fbac5a98
commit 8dd20c73e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -143,6 +143,11 @@ Mat3x3 Mat3x3::copy() const {
}
std::string Mat3x3::toString() const {
for (const auto& m : matrix) {
if (!std::isfinite(m))
return "[mat3x3: invalid values]";
}
return std::format("[mat3x3: {}, {}, {}, {}, {}, {}, {}, {}, {}]", matrix.at(0), matrix.at(1), matrix.at(2), matrix.at(3), matrix.at(4), matrix.at(5), matrix.at(6),
matrix.at(7), matrix.at(8));
}