Skip to content

Commit c1414a7

Browse files
authored
Merge pull request #2361 from bnbarham/flakey-compdb
Ensure the string passed to `PathIsRelativeW` is null terminated
2 parents b539999 + b3cb43f commit c1414a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/BuildServerIntegration/CompilationDatabase.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ enum CompilationDatabaseDecodingError: Error {
206206
fileprivate extension String {
207207
var isAbsolutePath: Bool {
208208
#if os(Windows)
209-
Array(self.utf16).withUnsafeBufferPointer { buffer in
210-
return !PathIsRelativeW(buffer.baseAddress)
209+
// PathIsRelativeW requires a null-terminated UTF16 encoded string
210+
return withCString(encodedAs: UTF16.self) { ptr in
211+
return !PathIsRelativeW(ptr)
211212
}
212213
#else
213214
return self.hasPrefix("/")

0 commit comments

Comments
 (0)