Skip to content

Commit

Permalink
LibAudio: Move format and BPS checks before VERIFYs in WAV loader
Browse files Browse the repository at this point in the history
It was accidentally checking the format/bits per sample too late,
which would crash with the assertion.
  • Loading branch information
Lubrsi authored and awesomekling committed Mar 1, 2021
1 parent 69df86c commit 152af3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Userland/Libraries/LibAudio/WavLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ bool WavLoaderPlugin::parse_header()
u16 audio_format = read_u16();
CHECK_OK("Audio format"); // incomplete read check
ok = ok && audio_format == 1; // WAVE_FORMAT_PCM
CHECK_OK("Audio format"); // value check
VERIFY(audio_format == 1);
CHECK_OK("Audio format"); // value check

m_num_channels = read_u16();
ok = ok && (m_num_channels == 1 || m_num_channels == 2);
Expand All @@ -211,8 +211,8 @@ bool WavLoaderPlugin::parse_header()
m_bits_per_sample = read_u16();
CHECK_OK("Bits per sample"); // incomplete read check
ok = ok && (m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);
VERIFY(m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);
CHECK_OK("Bits per sample"); // value check
VERIFY(m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);

// Read chunks until we find DATA
bool found_data = false;
Expand Down

0 comments on commit 152af3a

Please sign in to comment.