raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.26k stars 280 forks source link

GuiTextBox(): Fix buffer overrun from cursor index #405

Closed segcore closed 1 month ago

segcore commented 1 month ago

Fix a buffer overrun from using the global variable textBoxCursorIndex in GuiTextBox().

To reproduce overrun, have two GuiTextBox()es with different buffer sizes, and then the cursor index is shared between them, reading beyond the end of the array of the smaller buffer.

(Found because I run my debug builds with -fsanitize=address and this crashed my program :p )

raysan5 commented 1 month ago

@segcore Good catch! Thanks for the review!