commit b3e2f518e43b27817e1f06e2d3c34d7fd17ee96b parent b84bbef1f91ce664fca15b13b8a27f1e7bb5f888 Author: Christian Grothoff <christian@grothoff.org> Date: Wed, 29 Jul 2026 12:17:08 +0200 fix type promotion issue before shifting Diffstat:
| M | src/plugins/wav_extractor.c | | | 6 | ++++-- |
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/plugins/wav_extractor.c b/src/plugins/wav_extractor.c @@ -49,8 +49,10 @@ little_endian_to_host32 (uint32_t in) { unsigned char *ptr = (unsigned char *) ∈ - return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) - | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); + /* Widen before shifting: `unsigned char' promotes to `int', and + 0x80 << 24 overflows a 32 bit int. */ + return (((uint32_t) ptr[3]) << 24) | (((uint32_t) ptr[2]) << 16) + | (((uint32_t) ptr[1]) << 8) | ((uint32_t) ptr[0]); }