From 7eaa5e88441273aef8e7d9e7df2a5c084423a6fb Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 16 Aug 2025 14:37:38 +0200 Subject: [PATCH] Mesh: Fix crash MeshPy::setPoint & MeshPy::movePoint Fixes https://github.com/FreeCAD/FreeCAD/issues/18823 --- 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 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; }