From 44cd4faf83666d545d6a9424128c5926e5cfdcef Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 3 Feb 2018 14:40:57 +0100 Subject: [PATCH] exit(3), don't crash, when glfwCreateWindow fails glfwSetWindowPos was called on a NULL window, triggering an assert inside GLFW. Check for failure and exit cleanly by means of TraceLog(LOG_ERROR instead. --- src/core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core.c b/src/core.c index 54c440fd..648d586d 100644 --- a/src/core.c +++ b/src/core.c @@ -1822,18 +1822,21 @@ static void InitGraphicsDevice(int width, int height) // No-fullscreen window creation window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, NULL, NULL); + if (window) + { #if defined(PLATFORM_DESKTOP) - // Center window on screen - int windowPosX = displayWidth/2 - screenWidth/2; - int windowPosY = displayHeight/2 - screenHeight/2; + // Center window on screen + int windowPosX = displayWidth/2 - screenWidth/2; + int windowPosY = displayHeight/2 - screenHeight/2; - if (windowPosX < 0) windowPosX = 0; - if (windowPosY < 0) windowPosY = 0; + if (windowPosX < 0) windowPosX = 0; + if (windowPosY < 0) windowPosY = 0; - glfwSetWindowPos(window, windowPosX, windowPosY); + glfwSetWindowPos(window, windowPosX, windowPosY); #endif - renderWidth = screenWidth; - renderHeight = screenHeight; + renderWidth = screenWidth; + renderHeight = screenHeight; + } } if (!window)