Commit 8f4c2a8f9c98186a38be6e33c58af48cd4dc0849

Philipp Wiesemann 2015-03-06T21:29:25

Emscripten: Fixed ignoring return value of internal function. If the function Emscripten_ConvertUTF32toUTF8() failed (should currently not be possible) a not terminated string would have been sent as text input event.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c
index d61ff4f..6a04d4c 100644
--- a/src/video/emscripten/SDL_emscriptenevents.c
+++ b/src/video/emscripten/SDL_emscriptenevents.c
@@ -447,8 +447,9 @@ EM_BOOL
 Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
 {
     char text[5];
-    Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text);
-    SDL_SendKeyboardText(text);
+    if (Emscripten_ConvertUTF32toUTF8(keyEvent->charCode, text)) {
+        SDL_SendKeyboardText(text);
+    }
     return 1;
 }