getAttachNode BUG

cocos2dx 3.3final

Sprite3D:


AttachNode* Sprite3D::getAttachNode(const std::string& boneName)
{
    auto it = _attachments.find(boneName);
    if (it != _attachments.end())
        return it->second;
    
    if (_skeleton)
    {
       <pre class="brush:cpp; toolbar: true; auto-links: false;"> auto bone = _skeleton->getBoneByName(boneName);
    auto attachNode = AttachNode::create(bone);
    addChild(attachNode);
    _attachments = attachNode;
    return attachNode;
}

return nullptr;

}


没有判断bone是否存在,直接创建attachNode,导致crash。