Skip to content

Commit 514260e

Browse files
authored
Update Path.swift
1 parent 01849f8 commit 514260e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/TSCBasic/Path.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ public struct RelativePath: Hashable {
258258
self.init(PathImpl(string: string))
259259
} else {
260260
#if _runtime(_ObjC)
261-
let normalized: [Int8] = string.fileSystemRepresentation
262-
self.init(PathImpl(string: String(cString: normalized)))
261+
self.init(PathImpl(string: withUnsafeTemporaryAllocation(of: Int8.self, capacity: Int(PATH_MAX) + 1) {
262+
string.getFileSystemRepresentation($0.baseAddress, maxLength: $0.count)
263+
return String(cString: $0.baseAddress!)
264+
}))
263265
#else
264266
let normalized: UnsafePointer<Int8> = string.fileSystemRepresentation
265267
defer { normalized.deallocate() }

0 commit comments

Comments
 (0)