From bea56ad3dc6d799f058e48359f30a246ecd24418 Mon Sep 17 00:00:00 2001 From: Avery King Date: Wed, 3 Aug 2022 08:50:16 -0700 Subject: [PATCH] Fix missed conversions after multiplication Corresponds to commit 6c1e159 and a couple of missed CodeQL alerts. Signed-off-by: Avery King --- libraries/lib-math/Dither.cpp | 2 +- src/SpectrumAnalyst.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/lib-math/Dither.cpp b/libraries/lib-math/Dither.cpp index c45d9c9e88..e78482b9b6 100644 --- a/libraries/lib-math/Dither.cpp +++ b/libraries/lib-math/Dither.cpp @@ -264,7 +264,7 @@ void Dither::Apply(enum DitherType ditherType, // No need to dither, because source and destination // format are the same. Just copy samples. if (destStride == 1 && sourceStride == 1) - memcpy(dest, source, len * SAMPLE_SIZE(destFormat)); + memcpy(dest, source, static_cast(len) * SAMPLE_SIZE(destFormat)); else { if (sourceFormat == floatSample) diff --git a/src/SpectrumAnalyst.cpp b/src/SpectrumAnalyst.cpp index b0489a3ba9..87ffbc7e3d 100644 --- a/src/SpectrumAnalyst.cpp +++ b/src/SpectrumAnalyst.cpp @@ -352,8 +352,8 @@ float SpectrumAnalyst::GetProcessedValue(float freq0, float freq1) const float bin0, bin1, binwidth; if (mAlg == Spectrum) { - bin0 = freq0 * static_cast(mWindowSize) / mRate; - bin1 = freq1 * static_cast(mWindowSize) / mRate; + bin0 = static_cast(freq0) * mWindowSize / mRate; + bin1 = static_cast(freq1) * mWindowSize / mRate; } else { bin0 = freq0 * mRate; bin1 = freq1 * mRate;