From 6e20cda7fdc734ef60bb924fdf5a5260ba840983 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 10 Mar 2015 12:01:38 +0100 Subject: [PATCH] Fixed test for invalid timer values. Fixes #436 (properly). --- README.md | 1 + include/GLFW/glfw3.h | 7 ++++++- src/input.c | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9492aafb..1f0980f3 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ skills. - Nathan Sweet - TTK-Bandit - Sergey Tikhomirov + - A. Tombs - Samuli Tuomola - urraka - Jari Vetoniemi diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5fbbbaa1..d2720bd7 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3098,10 +3098,15 @@ GLFWAPI double glfwGetTime(void); /*! @brief Sets the GLFW timer. * * This function sets the value of the GLFW timer. It then continues to count - * up from that value. The value must be a positive finite number. + * up from that value. The value must be a positive finite number less than + * or equal to 18446744073.0, which is approximately 584.5 years. * * @param[in] time The new value, in seconds. * + * @remarks The upper limit of the timer is calculated as + * floor((264 - 1) / 109) and is due to implementations + * storing nanoseconds in 64 bits. The limit may be increased in the future. + * * @par Thread Safety * This function may only be called from the main thread. * diff --git a/src/input.c b/src/input.c index b3026065..0a8bd1fd 100644 --- a/src/input.c +++ b/src/input.c @@ -28,7 +28,6 @@ #include "internal.h" #include -#include #if defined(_MSC_VER) #include #endif @@ -593,7 +592,7 @@ GLFWAPI void glfwSetTime(double time) { _GLFW_REQUIRE_INIT(); - if (time != time || time - DBL_MAX == time || time < 0.0) + if (time != time || time < 0.0 || time > 18446744073.0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid time"); return;