Skip to content

Commit e95ace3

Browse files
authored
Merge pull request #1872 from compnerd/errors
NSData: fix an errno stomp
2 parents 480caee + 4080d37 commit e95ace3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Foundation/NSData.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,9 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
517517
if let auxFilePath = auxFilePath {
518518
try fm._fileSystemRepresentation(withPath: auxFilePath, { auxFilePathFsRep in
519519
if rename(auxFilePathFsRep, pathFsRep) != 0 {
520+
let savedErrno = errno
520521
try? FileManager.default.removeItem(atPath: auxFilePath)
521-
throw _NSErrorWithErrno(errno, reading: false, path: path)
522+
throw _NSErrorWithErrno(savedErrno, reading: false, path: path)
522523
}
523524
if let mode = mode {
524525
chmod(pathFsRep, mode)

0 commit comments

Comments
 (0)