Add checks for some invalid values to public API

There were no checks for invalid values or asserts for all invalid NULL
pointers to glfwSetWindowIcon or glfwCreateCursor.

Fixes #1862
This commit is contained in:
Camilla Löwy
2022-03-15 21:22:49 +01:00
parent 8d9231fe5e
commit 66a4882eb1
4 changed files with 33 additions and 3 deletions
+7
View File
@@ -764,9 +764,16 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
_GLFWcursor* cursor;
assert(image != NULL);
assert(image->pixels != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (image->width <= 0 || image->height <= 0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image dimensions for cursor");
return NULL;
}
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
cursor->next = _glfw.cursorListHead;
_glfw.cursorListHead = cursor;