浏览代码

LibAudio: Make `WavWriter` check if a file was set during destruction

`WavWriter` can be constructed without a file, which should probably be
made impossible at some point. For now, let's not crash `Piano` when you
close the application.
Jelle Raaijmakers 2 年之前
父节点
当前提交
0f22dfa634
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Userland/Libraries/LibAudio/WavWriter.cpp

+ 1 - 1
Userland/Libraries/LibAudio/WavWriter.cpp

@@ -58,7 +58,7 @@ void WavWriter::finalize()
     VERIFY(!m_finalized);
     VERIFY(!m_finalized);
     m_finalized = true;
     m_finalized = true;
 
 
-    if (m_file->is_open()) {
+    if (m_file && m_file->is_open()) {
         auto result = [&]() -> ErrorOr<void> {
         auto result = [&]() -> ErrorOr<void> {
             TRY(m_file->seek(0, SeekMode::SetPosition));
             TRY(m_file->seek(0, SeekMode::SetPosition));
             return TRY(write_header());
             return TRY(write_header());