Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.10.0
-
None
-
323b00e38c38cc864d136d70befd106400c50163
Description
The current move assignment operator implementation for QSharedDataPointer and QExplicitlySharedDataPointer is a simple swap of the left hand side and right hand side data pointers. I think this is not sufficient since the right hand side pointer isn't cleared afterwards.
When moving a reference from a shared pointer `p2` to `p1` like this
p1 = std::move(p2)
the old reference in `p1` is expected to be gone, possibly invoking the data destructor of the object `p1` was referring to. Due to the swap however the old `p1` data now lives on in `p2` and is destroyed on some later, unexpected occasion (or maybe even not at all).
Attachments
For Gerrit Dashboard: QTBUG-66322 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
219801,3 | QSharedDataPointer: use swap-and-move in the move constructor | 5.11 | qt/qtbase | Status: MERGED | +2 | 0 |