1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

FileSourceGui: Prevent potential integer overflow in updateWithStreamTime

UBSan reports the following error when replaying an IQ stream:

    ./plugins/samplesource/filesource/filesourcegui.cpp:331:29: runtime
    error: signed integer overflow: 2704064 * 1000 cannot be represented
    in type 'int'

By rearranging the calculation, we can be sure that the calculation never
overflows.
This commit is contained in:
Jason Gerecke 2018-04-20 21:52:57 -07:00
parent 7c67b7de7c
commit bc4d7adce7

View File

@ -328,8 +328,8 @@ void FileSourceGui::updateWithStreamTime()
int t_msec = 0;
if (m_sampleRate > 0){
t_msec = ((m_samplesCount * 1000) / m_sampleRate) % 1000;
t_sec = m_samplesCount / m_sampleRate;
t_msec = (m_samplesCount - (t_sec * m_sampleRate)) * 1000 / m_sampleRate;
}
QTime t(0, 0, 0, 0);