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.
pull/163/head
Jason Gerecke 2018-04-20 21:52:57 -07:00
rodzic 7c67b7de7c
commit bc4d7adce7
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -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);