File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -82,11 +82,12 @@ extension _SwiftNativeNSArrayWithContiguousStorage : _NSArrayCore {
82
82
83
83
if objects. isEmpty { return }
84
84
85
- // These objects are "returned" at +0, so treat them as values to
86
- // avoid retains.
87
- UnsafeMutablePointer < Int > ( aBuffer) . initialize ( from:
88
- UnsafeMutablePointer ( objects. baseAddress! + range. location) ,
89
- count: range. length)
85
+ // These objects are "returned" at +0, so treat them as pointer values to
86
+ // avoid retains. Copy bytes via a raw pointer to circumvent reference
87
+ // counting while correctly aliasing with all other pointer types.
88
+ UnsafeMutableRawPointer ( aBuffer) . copyBytes (
89
+ from: objects. baseAddress! + range. location,
90
+ count: range. length * strideof( AnyObject . self) )
90
91
}
91
92
}
92
93
You can’t perform that action at this time.
0 commit comments