diff --git a/README.md b/README.md index f31e14b5..8b11f9c9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. ## Changelog + - Bugfix: `glfwSetTime` silently accepted invalid values - [Cocoa] Bugfix: `glfwSetWindowSize` did not change the video mode for full screen windows - [X11] Added support for Cygwin-X diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index dd9f2073..94fe4aed 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3136,7 +3136,7 @@ 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. + * up from that value. The value must be a positive finite number. * * @param[in] time The new value, in seconds. * diff --git a/src/input.c b/src/input.c index 78a71693..b3026065 100644 --- a/src/input.c +++ b/src/input.c @@ -28,6 +28,7 @@ #include "internal.h" #include +#include #if defined(_MSC_VER) #include #endif @@ -591,6 +592,13 @@ GLFWAPI double glfwGetTime(void) GLFWAPI void glfwSetTime(double time) { _GLFW_REQUIRE_INIT(); + + if (time != time || time - DBL_MAX == time || time < 0.0) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid time"); + return; + } + _glfwPlatformSetTime(time); }