Merge pull request #630 from motiejus/patch-1

avoid UB in bit shifts
This commit is contained in:
Al B
2023-06-24 19:35:45 -07:00
committed by GitHub

View File

@@ -198,7 +198,7 @@ bool file_write_float(FILE *file, float value) {
} }
inline uint32_t file_deserialize_uint32(unsigned char *buf) { inline uint32_t file_deserialize_uint32(unsigned char *buf) {
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; return ((uint32_t)buf[0] << 24) | ((uint32_t)buf[1] << 16) | ((uint32_t)buf[2] << 8) | (uint32_t)buf[3];
} }
bool file_read_uint32(FILE *file, uint32_t *value) { bool file_read_uint32(FILE *file, uint32_t *value) {
@@ -243,7 +243,7 @@ bool file_write_uint32(FILE *file, uint32_t value) {
inline uint16_t file_deserialize_uint16(unsigned char *buf) { inline uint16_t file_deserialize_uint16(unsigned char *buf) {
return (buf[0] << 8) | buf[1]; return ((uint16_t)buf[0] << 8) | buf[1];
} }