mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 22:32:50 +00:00
Add validation of size limit and aspect ratio args
This commit is contained in:
+13
-6
@@ -521,6 +521,13 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (minwidth < 0 || minheight < 0 ||
|
||||
maxwidth < minwidth || maxheight < minheight)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window size limits");
|
||||
return;
|
||||
}
|
||||
|
||||
window->minwidth = minwidth;
|
||||
window->minheight = minheight;
|
||||
window->maxwidth = maxwidth;
|
||||
@@ -541,18 +548,18 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (numer <= 0 || denom <= 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window aspect ratio");
|
||||
return;
|
||||
}
|
||||
|
||||
window->numer = numer;
|
||||
window->denom = denom;
|
||||
|
||||
if (window->monitor || !window->resizable)
|
||||
return;
|
||||
|
||||
if (!denom)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Denominator cannot be zero");
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSetWindowAspectRatio(window, numer, denom);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user