mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-02-10 06:18:55 -06:00
fix: Potential overflow when calculating audio sample index
Fixes [https://github.com/WerWolv/ImHex/security/code-scanning/223](https://github.com/WerWolv/ImHex/security/code-scanning/223) To fix the problem, we need to ensure that the multiplication is performed using a larger integer type to avoid overflow. This can be achieved by casting one of the operands to `u64` before performing the multiplication. This way, the multiplication will be done in the larger type, preventing overflow. We will modify the line `index += frameCount * device->playback.channels;` to cast `frameCount` to `u64` before the multiplication. _Suggested fixes powered by Copilot Autofix. Review carefully before merging._ Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -56,7 +56,7 @@ namespace hex::plugin::visualizers {
|
||||
}
|
||||
|
||||
ma_copy_pcm_frames(pOutput, waveData.data() + index, frameCount, device->playback.format, device->playback.channels);
|
||||
index += frameCount * device->playback.channels;
|
||||
index += static_cast<u64>(frameCount) * device->playback.channels;
|
||||
};
|
||||
|
||||
ma_device_init(nullptr, &deviceConfig, &audioDevice);
|
||||
|
||||
Reference in New Issue
Block a user