clipboard: wrap pointer indexing in unsafe block (#6178)

pull/6182/head
Lukas Neubert 2020-08-20 10:33:12 +02:00 committed by GitHub
parent d8d707b4fe
commit 6eea13ecc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -133,7 +133,9 @@ fn to_wide(text string) &C.HGLOBAL {
if buf != C.HGLOBAL(C.NULL) { if buf != C.HGLOBAL(C.NULL) {
mut locked := &u16(C.GlobalLock(buf)) mut locked := &u16(C.GlobalLock(buf))
C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1, locked, len_required) C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1, locked, len_required)
locked[len_required - 1] = u16(0) unsafe {
locked[len_required - 1] = u16(0)
}
C.GlobalUnlock(buf) C.GlobalUnlock(buf)
} }
return buf return buf