Skip to content

Commit 69b4560

Browse files
committed
Platform: account for nul terminator
Ensure that we allocate the space for the trailing nul terminator in the string. We would otherwise be off by one when converting the string.
1 parent 6a92756 commit 69b4560

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftWin32/Platform/Win32+PropertyWrappers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public struct _Win32WindowText {
1919
guard szLength > 0 else { return nil }
2020

2121
let buffer: [WCHAR] = Array<WCHAR>(unsafeUninitializedCapacity: Int(szLength) + 1) {
22-
$1 = Int(GetWindowTextW(view.hWnd, $0.baseAddress!, CInt($0.count)))
22+
$1 = Int(GetWindowTextW(view.hWnd, $0.baseAddress!, CInt($0.count))) + 1
2323
}
2424
return String(decodingCString: buffer, as: UTF16.self)
2525
}

0 commit comments

Comments
 (0)