Linux: Include the null byte in joystick path

This potential bug was found thanks to gcc 8’s -Wstringop-truncation
warning.
This commit is contained in:
Kovid Goyal 2018-10-06 07:49:59 +05:30
parent 05a0166ebd
commit c498f4e8ab
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -228,7 +228,7 @@ static GLFWbool openJoystickDevice(const char* path)
return GLFW_FALSE; return GLFW_FALSE;
} }
strncpy(linjs.path, path, sizeof(linjs.path)); strncpy(linjs.path, path, sizeof(linjs.path) - 1);
memcpy(&js->linjs, &linjs, sizeof(linjs)); memcpy(&js->linjs, &linjs, sizeof(linjs));
pollAbsState(js); pollAbsState(js);
@ -431,4 +431,3 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
void _glfwPlatformUpdateGamepadGUID(char* guid) void _glfwPlatformUpdateGamepadGUID(char* guid)
{ {
} }