kurikaesu / userspace-tablet-driver-daemon

Linux device drivers for non-wacom (XP-Pen, Huion, Gaomon) graphics tablets and pen displays
GNU General Public License v3.0
65 stars 16 forks source link

fixing minor typeof() usage bug that affects non 64bits archs #72

Closed DaBlumer closed 1 year ago

DaBlumer commented 1 year ago

For some devices, in the ::handleNonUnifiedDialEvent() we declare an std::bitset<sizeof(data)> holding a bitset representation of an unsigned char with data being of type (unsigned char *). This is incorrect as sizeof(data) returns the size of a pointer in bytes, when we are expecting to have the number of bits in an unsigned char (8 bits). It happens to work on x64 archs because a pointer happens to be 8 bytes, in 32bit architectures this would create an std::bitset<4> which will cause an std::out_of_range exception on runtime when testing for the fifth bit for example.

kurikaesu commented 1 year ago

Thanks for the fix! Looks good to me!