From 2fd1c35904e74c258391a839dfdefd9d0d72fef7 Mon Sep 17 00:00:00 2001 From: pommicket Date: Fri, 19 Aug 2022 17:04:23 -0400 Subject: fixed actual bug: bad write when weird mouse buttons are pressed --- main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 791af49..ece1e94 100644 --- a/main.c +++ b/main.c @@ -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: { -- cgit v1.2.3