From b1beadd2e95b442d92b2cac406e0f077cbb99848 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 16 Dec 2021 00:09:05 -0600 Subject: [PATCH] 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. --- src/App/ObjectIdentifier.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index bf0afb7867..a809ce9acd 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -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; };