Skip to content
Verified Commit c00d98a2 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Make AttributeStorage explicitly shared

This solves a crash related to the fix in ItemChangelog where
-const access to ItemChangelog::attributes() const would return
a copy of (instead of reference to) AttributeStorage stored in
the hash map. When the copy was destroyed, any pointers to
Attributes stored in it would become invalid, causing crashes
due to use-after-free. This was commonly triggers by access
to attributes via Item::attribute<T>() which would obtain
the Attribute pointer from a temporary copy of the AttributeStorage
obtained from ItemChangelog.

By making AttributeStorage explicitly shared, a copy shares
the actual data with the original AttributeStorage stored in the
hash map in ItemChangelog. We use explicit sharing here, because
we don't want non-const access to the d-pointer to detach our
copy from the one in the ItemChangelog.
parent 8330daff
Pipeline #573359 passed with stage
in 9 minutes and 38 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment