@@ -1762,14 +1762,23 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
1762
1762
}
1763
1763
1764
1764
public struct Iterator : IteratorProtocol {
1765
- private let _data : Data
1765
+ // Both _data and _endIdx should be 'let' rather than 'var'.
1766
+ // They are 'var' so that the stored properties can be read
1767
+ // independently of the other contents of the struct. This prevents
1768
+ // an exclusivity violation when reading '_endIdx' and '_data'
1769
+ // while simultaneously mutating '_buffer' with the call to
1770
+ // withUnsafeMutablePointer(). Once we support accessing struct
1771
+ // let properties independently we should make these variables
1772
+ // 'let' again.
1773
+
1774
+ private var _data : Data
1766
1775
private var _buffer : (
1767
1776
UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 ,
1768
1777
UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 ,
1769
1778
UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 ,
1770
1779
UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 )
1771
1780
private var _idx : Data . Index
1772
- private let _endIdx : Data . Index
1781
+ private var _endIdx : Data . Index
1773
1782
1774
1783
fileprivate init ( _ data: Data ) {
1775
1784
_data = data
0 commit comments