From e809e6364db15bec778f3685320c6793b7b7c966 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Oct 2025 07:59:23 +0000 Subject: [PATCH] PyAPI: prevent indices below -1 being used by StructRNA.path_from_module Disable this as RNA paths don't support Python-style negative indexing. Ref !147255 --- source/blender/python/intern/bpy_rna.cc | 5 +++++ 1 file changed, 5 insertions(+) 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) {