mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 21:17:01 +00:00
Fixed unlikely buffer overrun in InputCharacters (thanks Daniel Collin)
This commit is contained in:
parent
48a944813c
commit
9f05a2bb16
@ -348,7 +348,7 @@ static size_t ImStrlenW(const ImWchar* str);
|
|||||||
void ImGuiIO::AddInputCharacter(ImWchar c)
|
void ImGuiIO::AddInputCharacter(ImWchar c)
|
||||||
{
|
{
|
||||||
const size_t n = ImStrlenW(InputCharacters);
|
const size_t n = ImStrlenW(InputCharacters);
|
||||||
if (n < sizeof(InputCharacters) / sizeof(InputCharacters[0]))
|
if (n + 1 < sizeof(InputCharacters) / sizeof(InputCharacters[0]))
|
||||||
{
|
{
|
||||||
InputCharacters[n] = c;
|
InputCharacters[n] = c;
|
||||||
InputCharacters[n+1] = 0;
|
InputCharacters[n+1] = 0;
|
||||||
|
2
imgui.h
2
imgui.h
@ -456,7 +456,7 @@ struct ImGuiIO
|
|||||||
bool KeyCtrl; // Keyboard modifier pressed: Control
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
||||||
bool KeyShift; // Keyboard modifier pressed: Shift
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
||||||
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
|
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
|
||||||
ImWchar InputCharacters[16]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
void AddInputCharacter(ImWchar); // Helper to add a new character into InputCharacters[]
|
void AddInputCharacter(ImWchar); // Helper to add a new character into InputCharacters[]
|
||||||
|
Loading…
Reference in New Issue
Block a user