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

Check sample rate is non-zero to avoid divide by zero

This commit is contained in:
Jon Beniston 2021-03-08 21:41:46 +00:00
parent 156d7b543a
commit 802749afd3

View File

@ -110,16 +110,21 @@ void FileInput::openFileStream()
m_sampleSize = header.sampleSize;
QString crcHex = QString("%1").arg(header.crc32 , 0, 16);
if (crcOK)
if (crcOK && (m_sampleRate > 0) && (m_sampleSize > 0))
{
qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
m_recordLengthMuSec = ((fileSize - sizeof(FileRecord::Header)) * 1000000UL) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
}
else
else if (!crcOK)
{
qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
m_recordLengthMuSec = 0;
}
else
{
qCritical("FileInput::openFileStream: invalid header");
m_recordLengthMuSec = 0;
}
if (getMessageQueueToGUI())
{