Since handleLyTreeOperation does not use this value if the node is unmanaged - as we have an early return in the case oldRefs is nullptr, here - I suggest inserting a check before the access.
template <typename Operation, typename OperationScope>
void handleLyTreeOperation(
DataNode* affectedNode,
Operation operation,
OperationScope scope,
std::shared_ptr<internal_refcount> newRefs)
{
std::vector<DataNode*> wrappedSiblings{affectedNode};
if (scope == OperationScope::AffectsFollowingSiblings) {
//stuff ignored
}
auto oldRefs = affectedNode->m_refs;
if (!oldRefs) {
// The node is an unmanaged node, we will do nothing.
operation();
return;
}
// stuff ignored
Steps to reproduce:
This is because inside unlink - here -
m_refs->context
is accessed whenm_refs
isnullptr
for unmanaged nodes.Since
handleLyTreeOperation
does not use this value if the node is unmanaged - as we have an early return in the caseoldRefs
isnullptr
, here - I suggest inserting a check before the access.