From 2dbe6516266a1b7078c073e6e8bec8bb961e1f73 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 20 Mar 2025 21:32:04 -0500 Subject: [PATCH] App: Check for an invalid enum before proceeding --- src/App/PropertyStandard.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index b7eda1a93e..77f12cd513 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -601,7 +601,11 @@ bool PropertyEnumeration::getPyPathValue(const ObjectIdentifier& path, Py::Objec std::string p = path.getSubPathStr(); if (p == ".Enum" || p == ".All") { Base::PyGILStateLocker lock; - Py::Tuple res(_enum.maxValue() + 1); + auto maxEnumValue = _enum.maxValue(); + if (maxEnumValue < 0) { + return false; // The enum is invalid + } + Py::Tuple res(maxEnumValue + 1); std::vector enums = _enum.getEnumVector(); PropertyString tmp; for (int i = 0; i < int(enums.size()); ++i) {