Windows: Fixed ignoring return value of internal function.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 06 Mar 2015 21:34:10 +0100
changeset 9379 ff0e77a2f48c
parent 9378 71743b696c06
child 9380 07b7c1005a23
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.
src/video/windows/SDL_windowsevents.c
--- a/src/video/windows/SDL_windowsevents.c	Fri Mar 06 21:29:25 2015 +0100
+++ b/src/video/windows/SDL_windowsevents.c	Fri Mar 06 21:34:10 2015 +0100
@@ -559,10 +559,11 @@
 
             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);
+                    }
                 }
             }
         }