From c58473407d237008db3f5ce713c595eb4675e1e6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 2 Jan 2025 14:31:27 +0100 Subject: [PATCH] Mesh: Fix crash MeshPy::setPoint & MeshPy::movePoint --- src/Mod/Mesh/App/MeshPyImp.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 0045de4c49cd..53230a2c4789 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; }