diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 05f301e7de9..9c3b2e8ce3a 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -4016,6 +4016,7 @@ PyDoc_STRVAR( " The incomplete path will be printed in the error message.\n"); static PyObject *pyrna_struct_path_from_module(BPy_StructRNA *self, PyObject *args) { + const char *error_prefix = "path_from_module(...)"; const char *name = nullptr; PropertyRNA *prop; int index = -1; @@ -4025,6 +4026,10 @@ static PyObject *pyrna_struct_path_from_module(BPy_StructRNA *self, PyObject *ar if (!PyArg_ParseTuple(args, "|si:path_from_module", &name, &index)) { return nullptr; } + if (index < -1) { + PyErr_Format(PyExc_ValueError, "%s: indices below -1 are not supported", error_prefix); + return nullptr; + } std::optional path; if (name) {