diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-29 22:47:53 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-29 22:50:54 +0100 |
commit | cc5fab28af0a37aa48a6f445e1ac5cc5ef80f933 (patch) | |
tree | 67b76c0f5e9d50db38e293f086570dcfdc7d13dc | |
parent | a3f7127e7250196ce3cb7224739dffa2f10bf72e (diff) |
pcm/FloatConvert: fix compile-time integer overflow for S32
The compile-time calculation for `factor` overflows because `1<<31`
cannot be represented by `int`. By casting to `uintmax_t` first, we
can avoid this overflow.
Closes #380
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/pcm/FloatConvert.hxx | 2 |
2 files changed, 2 insertions, 1 deletions
@@ -1,6 +1,7 @@ ver 0.20.23 (not yet released) * protocol - emit "player" idle event when restarting the current song +* fix broken float to s32 conversion * new clang crash bug workaround ver 0.20.22 (2018/10/23) diff --git a/src/pcm/FloatConvert.hxx b/src/pcm/FloatConvert.hxx index 2270fbb90..70b00bcba 100644 --- a/src/pcm/FloatConvert.hxx +++ b/src/pcm/FloatConvert.hxx @@ -34,7 +34,7 @@ struct FloatToIntegerSampleConvert { typedef typename SrcTraits::long_type SL; typedef typename DstTraits::value_type DV; - static constexpr SV factor = 1 << (DstTraits::BITS - 1); + static constexpr SV factor = uintmax_t(1) << (DstTraits::BITS - 1); static_assert(factor > 0, "Wrong factor"); gcc_const |