From 06865c78c781a22e4afc300ee743937f2307a556 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 31 Dec 2020 01:00:11 -0700 Subject: [PATCH] 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(). --- Libraries/LibAudio/WavWriter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Libraries/LibAudio/WavWriter.cpp b/Libraries/LibAudio/WavWriter.cpp index 6fdfbcbae7..e60c5ccfd9 100644 --- a/Libraries/LibAudio/WavWriter.cpp +++ b/Libraries/LibAudio/WavWriter.cpp @@ -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; }