Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair for Issue #330 #333

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions gui-lib/mred/private/wx/cocoa/key-translate.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@

;; The strings used to store output from UCKeyTranslate is only allocated once:
(define max-string-length 255)
(define output-chars (malloc _UniChar max-string-length))
(define output-chars (malloc _UniChar (add1 max-string-length))) ; leave room for a terminator

;; Dead key state
; A pointer to an unsigned 32-bit value, initialized to zero.
Expand Down Expand Up @@ -490,10 +490,11 @@
max-string-length
actual-string-length
output-chars)
; get the number of characters returned, and convert to string
;; get the number of characters returned, and convert to string;
;; the characters are UTF-16
(define n (max 0 (min max-string-length (unbox actual-string-length))))
(list->string (for/list ([i (in-range n)])
(integer->char (ptr-ref output-chars _UniChar i)))))
(ptr-set! output-chars _UniChar n 0) ; ensure nul terminator
(cast output-chars _pointer _string/utf-16))

;;;
;;; Conversions back and forth between characters and key codes.
Expand Down
Loading