Commit 060d243f6652ca82c33f5499a44fdddc116f1aca

Philipp Wiesemann 2015-03-06T21:34:10

Windows: Fixed ignoring return value of internal function. If the function WIN_ConvertUTF32toUTF8() failed (should currently not be possible) a not terminated string would have been sent as text input event. This also fixed converting characters more often than needed on key repetition.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 9f2eff3..524e67a 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -559,10 +559,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
             GetKeyboardState(keyboardState);
             if (ToUnicode(wParam, (lParam >> 16) & 0xff, keyboardState, (LPWSTR)&utf32, 1, 0) > 0) {
-                WORD repetition;
-                for (repetition = lParam & 0xffff; repetition > 0; repetition--) {
-                    WIN_ConvertUTF32toUTF8(utf32, text);
-                    SDL_SendKeyboardText(text);
+                if (WIN_ConvertUTF32toUTF8(utf32, text)) {
+                    WORD repetition;
+                    for (repetition = lParam & 0xffff; repetition > 0; repetition--) {
+                        SDL_SendKeyboardText(text);
+                    }
                 }
             }
         }