Parcourir la source

Linux: Include the null byte in joystick path

This potential bug was found thanks to gcc 8’s -Wstringop-truncation
warning.
Emmanuel Gil Peyrot il y a 7 ans
Parent
commit
e75af5f531
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      src/linux_joystick.c

+ 1 - 1
src/linux_joystick.c

@@ -228,7 +228,7 @@ static GLFWbool openJoystickDevice(const char* path)
         return GLFW_FALSE;
     }
 
-    strncpy(linjs.path, path, sizeof(linjs.path));
+    strncpy(linjs.path, path, sizeof(linjs.path) - 1);
     memcpy(&js->linjs, &linjs, sizeof(linjs));
 
     pollAbsState(js);