diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 7e9b1d85f2..4ca5abb7c4 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -903,7 +903,13 @@ PyObject* MeshPy::setPoint(PyObject* args) PY_TRY { - getMeshObjectPtr()->setPoint(index, static_cast(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(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; }