This commit is contained in:
Mingjie Shen 2025-01-19 07:29:51 +00:00 committed by GitHub
commit b479f38136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,6 +36,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <limits.h>
#include "linmath.h" #include "linmath.h"
@ -103,7 +104,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
{ {
case GLFW_KEY_UP: case GLFW_KEY_UP:
{ {
if (swap_interval + 1 > swap_interval) if (swap_interval <= INT_MAX - 1)
set_swap_interval(window, swap_interval + 1); set_swap_interval(window, swap_interval + 1);
break; break;
} }
@ -112,12 +113,12 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
{ {
if (swap_tear) if (swap_tear)
{ {
if (swap_interval - 1 < swap_interval) if (swap_interval >= INT_MIN + 1)
set_swap_interval(window, swap_interval - 1); set_swap_interval(window, swap_interval - 1);
} }
else else
{ {
if (swap_interval - 1 >= 0) if (swap_interval >= 1)
set_swap_interval(window, swap_interval - 1); set_swap_interval(window, swap_interval - 1);
} }
break; break;