summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-08-19 17:04:23 -0400
committerpommicket <pommicket@gmail.com>2022-08-19 17:04:23 -0400
commit2fd1c35904e74c258391a839dfdefd9d0d72fef7 (patch)
treeef64015eeb41d3a8d9d9b9d473eaeeb10c88e6ac /main.c
parenta97059abea8a15fc26c3ddad66951a04e68fda23 (diff)
fixed actual bug: bad write when weird mouse buttons are pressed
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files 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: {