Skip to content

Check _ptr != ptr is not enough in AutoPtr.assign #3979

@funny-falcon

Description

@funny-falcon

if (&ptr != this)
{
if (_ptr) _ptr->release();
_ptr = ptr._ptr;
if (_ptr) _ptr->duplicate();
}

New object could be one referenced by old with it's internal AutoPtr.
If we release old pointer before duplicate new we could have dangled pointer problem already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions