diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 57f82eae..d6c834fe 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -548,7 +548,6 @@ GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun); #define GLFW_MONITOR_PARAM_I_PHYS_HEIGHT 2 #define GLFW_MONITOR_PARAM_I_SCREEN_X_POS 3 #define GLFW_MONITOR_PARAM_I_SCREEN_Y_POS 4 -#define GLFW_MONITOR_PARAM_S_NAME_LEN 30 /* Monitor types */ typedef struct _GLFWmonitor* GLFWmonitor; diff --git a/src/internal.h b/src/internal.h index d7d71aeb..d31aeebd 100644 --- a/src/internal.h +++ b/src/internal.h @@ -225,7 +225,7 @@ struct _GLFWmonitor void* userPointer; - char deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN+1]; + char* deviceName; // physical dimensions in millimeters. int physicalWidth; int physicalHeight; diff --git a/src/win32_display.c b/src/win32_display.c index 2743972a..1d0518ca 100644 --- a/src/win32_display.c +++ b/src/win32_display.c @@ -52,8 +52,9 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, DISPLAY_DEVICE* adapte DeleteDC(dc); - memcpy((*current)->deviceName, monitor->DeviceName, GLFW_MONITOR_PARAM_S_NAME_LEN+1); - (*current)->deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN] = '\0'; + (*monitor)->deviceName = _glfwMalloc(strlen(monitor->DeviceName) + 1); + memcpy((*current)->deviceName, monitor->DeviceName, strlen(monitor->DeviceName) + 1); + (*current)->deviceName[strlen(monitor->DeviceName)] = '\0'; (*current)->screenXPosition = setting->dmPosition.x; (*current)->screenYPosition = setting->dmPosition.y; @@ -68,6 +69,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor) result = monitor->next; + _glfwFree(monitor->deviceName); _glfwFree(monitor); return result; diff --git a/src/x11_display.c b/src/x11_display.c index bdc37bb9..6d9feccb 100644 --- a/src/x11_display.c +++ b/src/x11_display.c @@ -47,8 +47,9 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, XRROutputInfo* outputI (*current)->physicalWidth = outputInfo->mm_width; (*current)->physicalHeight = outputInfo->mm_height; - memcpy((*current)->deviceName, outputInfo->name, GLFW_MONITOR_PARAM_S_NAME_LEN+1); - (*current)->deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN] = '\0'; + (*monitor)->deviceName = _glfwMalloc(strlen(outputInfo->name) + 1); + memcpy((*current)->deviceName, outputInfo->name, strlen(outputInfo->name) + 1); + (*current)->deviceName[strlen(outputInfo->name)] = '\0'; (*current)->screenXPosition = crtcInfo->x; (*current)->screenYPosition = crtcInfo->y; @@ -68,6 +69,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor) XRRFreeOutputInfo(monitor->X11.output); #endif /*_GLFW_HAS_XRANDR*/ + _glfwFree(monitor->deviceName); _glfwFree(monitor); return result;