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.
Please register or sign in to comment