mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Wayland: Check for buffer creation failure
This prevents unusable decoration objects from being created, and invalid cursors from being returned to the user.
This commit is contained in:
parent
754b7feaa1
commit
ab16fcc8db
@ -186,7 +186,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
|||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Creating a buffer file for %d B failed: %m",
|
"Wayland: Creating a buffer file for %d B failed: %m",
|
||||||
length);
|
length);
|
||||||
return GLFW_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
@ -195,7 +195,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
|||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: mmap failed: %m");
|
"Wayland: mmap failed: %m");
|
||||||
close(fd);
|
close(fd);
|
||||||
return GLFW_FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
|
pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
|
||||||
@ -265,6 +265,8 @@ static void createDecorations(_GLFWwindow* window)
|
|||||||
|
|
||||||
if (!window->wl.decorations.buffer)
|
if (!window->wl.decorations.buffer)
|
||||||
window->wl.decorations.buffer = createShmBuffer(&image);
|
window->wl.decorations.buffer = createShmBuffer(&image);
|
||||||
|
if (!window->wl.decorations.buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
createDecoration(&window->wl.decorations.top, window->wl.surface,
|
createDecoration(&window->wl.decorations.top, window->wl.surface,
|
||||||
window->wl.decorations.buffer, opaque,
|
window->wl.decorations.buffer, opaque,
|
||||||
@ -1308,6 +1310,9 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
cursor->wl.buffer = createShmBuffer(image);
|
cursor->wl.buffer = createShmBuffer(image);
|
||||||
|
if (!cursor->wl.buffer)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
cursor->wl.width = image->width;
|
cursor->wl.width = image->width;
|
||||||
cursor->wl.height = image->height;
|
cursor->wl.height = image->height;
|
||||||
cursor->wl.xhot = xhot;
|
cursor->wl.xhot = xhot;
|
||||||
|
Loading…
Reference in New Issue
Block a user