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:
parent
7c67b7de7c
commit
bc4d7adce7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user