From 0c70eb8d5c7090e0293a192239796d1a0933b3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 17 Aug 2017 14:25:10 +0200 Subject: [PATCH] Unify error message buffer lengths --- src/init.c | 2 +- src/internal.h | 4 +++- src/win32_init.c | 4 ++-- src/x11_init.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/init.c b/src/init.c index fd86c5be..7d3678fa 100644 --- a/src/init.c +++ b/src/init.c @@ -148,7 +148,7 @@ static void terminate(void) void _glfwInputError(int code, const char* format, ...) { _GLFWerror* error; - char description[1024]; + char description[_GLFW_MESSAGE_SIZE]; if (format) { diff --git a/src/internal.h b/src/internal.h index fdff84d0..a95d1f86 100644 --- a/src/internal.h +++ b/src/internal.h @@ -54,6 +54,8 @@ #define _GLFW_POLL_BUTTONS 2 #define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS) +#define _GLFW_MESSAGE_SIZE 1024 + typedef int GLFWbool; typedef struct _GLFWerror _GLFWerror; @@ -263,7 +265,7 @@ struct _GLFWerror { _GLFWerror* next; int code; - char description[1024]; + char description[_GLFW_MESSAGE_SIZE]; }; /*! @brief Initialization configuration. diff --git a/src/win32_init.c b/src/win32_init.c index 231b0a28..06eb44cb 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -412,8 +412,8 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source) // void _glfwInputErrorWin32(int error, const char* description) { - WCHAR buffer[1024] = L""; - char message[2048] = ""; + WCHAR buffer[_GLFW_MESSAGE_SIZE] = L""; + char message[_GLFW_MESSAGE_SIZE] = ""; FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | diff --git a/src/x11_init.c b/src/x11_init.c index 3bae1fa3..c4e84474 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -779,7 +779,7 @@ void _glfwReleaseErrorHandlerX11(void) // void _glfwInputErrorX11(int error, const char* message) { - char buffer[8192]; + char buffer[_GLFW_MESSAGE_SIZE]; XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode, buffer, sizeof(buffer));