Skip to content

Commit abc9ac7

Browse files
authored
Merge pull request swiftlang#1874 from compnerd/forgotten-memory
2 parents ac850f9 + cbdbe61 commit abc9ac7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Foundation/NSPathUtilities.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,9 @@ internal func _NSCreateTemporaryFile(_ filePath: String) throws -> (Int32, Strin
612612
var buf: [UInt16] = Array<UInt16>(repeating: 0, count: maxLength)
613613
let length = GetTempPathW(DWORD(MAX_PATH), &buf)
614614
precondition(length <= MAX_PATH - 14, "temp path too long")
615-
if GetTempFileNameW(buf, unsafeBitCast("SCF".utf16, to: LPCWSTR?.self), 0,
616-
&buf) == FALSE {
615+
if "SCF".withCString(encodedAs: UTF16.self, {
616+
return GetTempFileNameW(buf, $0, 0, &buf)
617+
}) == FALSE {
617618
throw _NSErrorWithErrno(Int32(GetLastError()), reading: false,
618619
path: filePath)
619620
}

0 commit comments

Comments
 (0)