2
0
Эх сурвалжийг харах

Unify error message buffer lengths

Camilla Löwy 8 жил өмнө
parent
commit
0c70eb8d5c
4 өөрчлөгдсөн 7 нэмэгдсэн , 5 устгасан
  1. 1 1
      src/init.c
  2. 3 1
      src/internal.h
  3. 2 2
      src/win32_init.c
  4. 1 1
      src/x11_init.c

+ 1 - 1
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)
     {

+ 3 - 1
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.

+ 2 - 2
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 |

+ 1 - 1
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));