fix: Division by zero in sound visualizer. (#2593)

Can happen if input is less than 2400*channels number of points. The fix
is detecting it and throwing an error.
This commit is contained in:
paxcut
2026-01-02 08:03:52 -07:00
committed by GitHub
parent 731cf10207
commit ed583d8bd1

View File

@@ -30,8 +30,10 @@ namespace hex::plugin::visualizers {
if (sampleRate == 0)
throw std::logic_error(fmt::format("Invalid sample rate: {}", sampleRate));
else if (channels == 0)
if (channels == 0)
throw std::logic_error(fmt::format("Invalid channel count: {}", channels));
if (downSampling == 0)
throw std::logic_error(fmt::format("Invalid down sampling factor: {} / 2400 / {} = {}", wavePattern->getSize(), channels, downSampling));
u64 sampledIndex;
if (shouldReset) {
waveData.clear();