Fix: UBSan division by zero runtime error in intern/shrinkwrap.cc

This error would occur because the quadratic equation solving code didn't
check for `a` being non-zero. Fixed by adding the additional check. This
can be tested and reproduced using the `ShrinkwrapTargetNormalProject2`
`modifiers` test.

Pull Request: https://projects.blender.org/blender/blender/pulls/133273
This commit is contained in:
Jonas Holzman
2025-01-20 10:05:34 +01:00
parent 723cd87d49
commit 5472ffeae3

View File

@@ -956,7 +956,7 @@ static void target_project_edge(const ShrinkwrapTreeData *tree,
float c = d0co - d0v0;
float det = b * b - 4 * a * c;
if (det >= 0) {
if (det >= 0 && a != 0) {
const float epsilon = 1e-6f;
float sdet = sqrtf(det);
float hit_co[3], hit_no[3];