diff --git a/ion/src/simulator/shared/events.cpp b/ion/src/simulator/shared/events.cpp index e2e3e766a..6300c9999 100644 --- a/ion/src/simulator/shared/events.cpp +++ b/ion/src/simulator/shared/events.cpp @@ -1,7 +1,6 @@ #include "events.h" #include "haptics.h" #include -#include namespace Ion { namespace Events { @@ -11,7 +10,7 @@ void didPressNewKey() { } char * sharedExternalTextBuffer() { - static char buffer[32]; + static char buffer[sharedExternalTextBufferSize]; return buffer; } diff --git a/ion/src/simulator/shared/events.h b/ion/src/simulator/shared/events.h index 609d09b52..9896b88e7 100644 --- a/ion/src/simulator/shared/events.h +++ b/ion/src/simulator/shared/events.h @@ -2,6 +2,7 @@ #define ION_SIMULATOR_EVENTS_H #include +#include namespace Ion { namespace Simulator { @@ -15,6 +16,7 @@ void logAfter(int numberOfEvents); namespace Events { +static constexpr size_t sharedExternalTextBufferSize = sizeof(SDL_TextInputEvent::text); char * sharedExternalTextBuffer(); constexpr Event ExternalText = Event::Special(6); diff --git a/ion/src/simulator/shared/events_keyboard.cpp b/ion/src/simulator/shared/events_keyboard.cpp index fcb6f16b4..f4867cdf8 100644 --- a/ion/src/simulator/shared/events_keyboard.cpp +++ b/ion/src/simulator/shared/events_keyboard.cpp @@ -170,7 +170,7 @@ static Event eventFromSDLTextInputEvent(SDL_TextInputEvent event) { return None; } Ion::Events::removeShift(); - strlcpy(sharedExternalTextBuffer(), event.text, strlen(event.text) + 1); + strlcpy(sharedExternalTextBuffer(), event.text, sharedExternalTextBufferSize); return ExternalText; }