Core: Fix std::string init from null pointer

Constructing a string from a null pointer is undefined behavior: it
turned out to work with gcc and MSVC, but with XCode/clang it results in
a segmentation fault. Theis fix assumes that the expected behavior is to
yield an empty string.
This commit is contained in:
Chris Hennes
2021-12-16 00:09:05 -06:00
parent b918517d22
commit d9afcacf6f

View File

@@ -1678,12 +1678,16 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result,
}
}
auto &propset = (*deps)[obj];
// inserting a null name in the propset indicates the dependency is
// inserting a blank name in the propset indicates the dependency is
// on all properties of the corresponding object.
if(propset.size()!=1 || propset.begin()->size()) {
if(!propName)
if (propset.size() != 1 || propset.begin()->size()) {
if (!propName) {
propset.clear();
propset.insert(propName);
propset.insert("");
}
else {
propset.insert(propName);
}
}
return;
};