Mesh: Fix crash MeshPy::setPoint & MeshPy::movePoint

Fixes https://github.com/FreeCAD/FreeCAD/issues/18823
This commit is contained in:
wmayer
2025-08-16 14:37:38 +02:00
committed by Chris Hennes
parent 9ee6e592b1
commit 7eaa5e8844

View File

@@ -903,7 +903,13 @@ PyObject* MeshPy::setPoint(PyObject* args)
PY_TRY
{
getMeshObjectPtr()->setPoint(index, static_cast<Base::VectorPy*>(pnt)->value());
MeshObject* mesh = getMeshObjectPtr();
if (index >= mesh->countPoints()) {
Base::IndexError exc("index out of range");
exc.setPyException();
return nullptr;
}
mesh->setPoint(index, static_cast<Base::VectorPy*>(pnt)->value());
}
PY_CATCH;
@@ -935,7 +941,14 @@ PyObject* MeshPy::movePoint(PyObject* args)
return nullptr;
} while (false);
getMeshObjectPtr()->movePoint(index, vec);
MeshObject* mesh = getMeshObjectPtr();
if (index >= mesh->countPoints()) {
Base::IndexError exc("index out of range");
exc.setPyException();
return nullptr;
}
mesh->movePoint(index, vec);
Py_Return;
}