Refactor: Lattice deform: prevent incrementing nullptr

The lattice deform code would always call `co += 3` in a loop, even when
co is `nullptr`. This is invoking undefined behaviour, and causes UBSAN
warnings.

Pull Request: https://projects.blender.org/blender/blender/pulls/121396
This commit is contained in:
Sybren A. Stüvel
2024-05-07 14:23:27 +02:00
parent 9a5366cf8e
commit 18cccafeaf

View File

@@ -113,11 +113,12 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob
for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) {
for (v = 0, fv = lt->fv; v < lt->pntsv; v++, fv += lt->dv) {
for (u = 0, fu = lt->fu; u < lt->pntsu; u++, co += 3, fp += 3, fu += lt->du) {
for (u = 0, fu = lt->fu; u < lt->pntsu; u++, fp += 3, fu += lt->du) {
if (dl) {
fp[0] = co[0] - fu;
fp[1] = co[1] - fv;
fp[2] = co[2] - fw;
co += 3;
}
else {
fp[0] = bp->vec[0] - fu;