mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion/events] Fix ExternalText buffer size
The size of the ExternalText events shared buffer is now defined as the size of the SDL_TextInputEvent 'text' field, as it should. Also fix a wrong parameter being passed to a strlcpy. Change-Id: I6a57d49d61fec8a009c4711efce564c65544e571
This commit is contained in:
committed by
Émilie Feral
parent
b0b6fe33c9
commit
aadf8f5716
@@ -1,7 +1,6 @@
|
||||
#include "events.h"
|
||||
#include "haptics.h"
|
||||
#include <ion/events.h>
|
||||
#include <SDL.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Events {
|
||||
@@ -11,7 +10,7 @@ void didPressNewKey() {
|
||||
}
|
||||
|
||||
char * sharedExternalTextBuffer() {
|
||||
static char buffer[32];
|
||||
static char buffer[sharedExternalTextBufferSize];
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ION_SIMULATOR_EVENTS_H
|
||||
|
||||
#include <ion/events.h>
|
||||
#include <SDL.h>
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user