LibAudio: Make it so that an unused WavWriter is destructible

WavWriter::finalize didn't check that m_file was actually valid before
trying to seek and close it. The file is only set by set_file, so it's
not an invariant. Just add a null guard to finalize().
This commit is contained in:
Andrew Kaster 2020-12-31 01:00:11 -07:00 committed by Andreas Kling
parent 644f5ec160
commit 06865c78c7
Notes: sideshowbarker 2024-07-19 00:18:03 +09:00

View file

@ -70,9 +70,11 @@ void WavWriter::finalize()
{
ASSERT(!m_finalized);
m_finalized = true;
m_file->seek(0);
write_header();
m_file->close();
if (m_file) {
m_file->seek(0);
write_header();
m_file->close();
}
m_data_sz = 0;
}