From 20af66f271a8aca9e3c2fde8cefd56f045b5606b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sat, 29 Dec 2012 20:01:33 +0100 Subject: [PATCH] Added OOM error reporting to X11 mode enumeration. --- src/x11_monitor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index ecc7c3b9..20b76e8f 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -354,6 +354,11 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) _glfwLibrary.X11.root); result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * count); + if (!result) + { + _glfwSetError(GLFW_OUT_OF_MEMORY, NULL); + return NULL; + } for (i = 0; i < count; i++) { @@ -401,7 +406,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) if (result == NULL) { *found = 1; + result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode)); + if (!result) + { + _glfwSetError(GLFW_OUT_OF_MEMORY, NULL); + return NULL; + } result[0].width = DisplayWidth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);