App: Check for an invalid enum before proceeding

This commit is contained in:
Chris Hennes
2025-03-20 21:32:04 -05:00
committed by Benjamin Nauck
parent c2df0a1315
commit 00e648220a

View File

@@ -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<std::string> enums = _enum.getEnumVector();
PropertyString tmp;
for (int i = 0; i < int(enums.size()); ++i) {