LibAudio: Move format and BPS checks before VERIFYs in WAV loader

It was accidentally checking the format/bits per sample too late,
which would crash with the assertion.
This commit is contained in:
Luke 2021-02-28 22:46:19 +00:00 committed by Andreas Kling
parent 69df86c1d6
commit 152af3a297
Notes: sideshowbarker 2024-07-18 21:50:15 +09:00

View File

@ -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);
@ -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;