diff options
author | pommicket <pommicket@gmail.com> | 2022-08-19 17:04:23 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-08-19 17:04:23 -0400 |
commit | 2fd1c35904e74c258391a839dfdefd9d0d72fef7 (patch) | |
tree | ef64015eeb41d3a8d9d9b9d473eaeeb10c88e6ac /main.c | |
parent | a97059abea8a15fc26c3ddad66951a04e68fda23 (diff) |
fixed actual bug: bad write when weird mouse buttons are pressed
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -547,9 +547,6 @@ int main(int argc, char **argv) { #endif while (!ted->quit) { - #if DEBUG - //printf("\033[H\033[2J"); - #endif double frame_start = time_get_seconds(); SDL_Event event; @@ -639,9 +636,11 @@ int main(int argc, char **argv) { } break; case SDL_MOUSEBUTTONUP: { Uint8 button = event.button.button; - v2 pos = V2((float)event.button.x, (float)event.button.y); - if (ted->nmouse_releases[button] < arr_count(ted->mouse_releases[button])) { - ted->mouse_releases[button][ted->nmouse_releases[button]++] = pos; + if (button < arr_count(ted->nmouse_releases)) { + v2 pos = V2((float)event.button.x, (float)event.button.y); + if (ted->nmouse_releases[button] < arr_count(ted->mouse_releases[button])) { + ted->mouse_releases[button][ted->nmouse_releases[button]++] = pos; + } } } break; case SDL_MOUSEMOTION: { |