diff --git a/Foundation/NSCalendar.swift b/Foundation/NSCalendar.swift index e3b427f19e..b14ce2778d 100644 --- a/Foundation/NSCalendar.swift +++ b/Foundation/NSCalendar.swift @@ -583,8 +583,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding { var at: CFAbsoluteTime = date.timeIntervalSinceReferenceDate let res: Bool = withUnsafeMutablePointer(to: &at) { t in + let count = Int32(vector.count) return vector.withUnsafeMutableBufferPointer { (vectorBuffer: inout UnsafeMutableBufferPointer) in - return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, Int32(vector.count)) + return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, count) } } @@ -603,8 +604,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding { return intArrayBuffer.baseAddress!.advanced(by: idx) } + let count = Int32(vector.count) return vector.withUnsafeMutableBufferPointer { (vecBuffer: inout UnsafeMutableBufferPointer>) in - return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, Int32(vector.count)) + return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, count) } } if res { diff --git a/TestFoundation/TestNSData.swift b/TestFoundation/TestNSData.swift index 221daa35e8..510ff85d4a 100644 --- a/TestFoundation/TestNSData.swift +++ b/TestFoundation/TestNSData.swift @@ -930,11 +930,11 @@ extension TestNSData { // Mutate it bytes.pointee = 0x67 XCTAssertEqual(bytes.pointee, 0x67, "First byte should be 0x67") - XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67") - - // Verify that the first data is still correct - XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68") } + XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67") + + // Verify that the first data is still correct + XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68") }