diff --git a/Libraries/LibWeb/WebAudio/AnalyserNode.cpp b/Libraries/LibWeb/WebAudio/AnalyserNode.cpp index 24cd3767d330..194fecc2b3a1 100644 --- a/Libraries/LibWeb/WebAudio/AnalyserNode.cpp +++ b/Libraries/LibWeb/WebAudio/AnalyserNode.cpp @@ -259,7 +259,7 @@ WebIDL::ExceptionOr AnalyserNode::get_byte_time_domain_data(GC::Root AnalyserNode::set_fft_size(unsigned long fft_size) { - if (fft_size < 32 || fft_size > 32768 || (fft_size & (fft_size - 1)) != 0) + if (fft_size < 32 || fft_size > 32768 || !is_power_of_two(fft_size)) return WebIDL::IndexSizeError::create(realm(), "Analyser node fftSize not a power of 2 between 32 and 32768"_string); // reset previous block to 0s @@ -304,9 +304,6 @@ WebIDL::ExceptionOr AnalyserNode::set_smoothing_time_constant(double smoot WebIDL::ExceptionOr> AnalyserNode::construct_impl(JS::Realm& realm, GC::Ref context, AnalyserOptions const& options) { - if (options.fft_size < 32 || options.fft_size > 32768 || !is_power_of_two(options.fft_size)) - return WebIDL::IndexSizeError::create(realm, "Analyser node fftSize not a power of 2 between 32 and 32768"_string); - if (options.min_decibels >= options.max_decibels) return WebIDL::IndexSizeError::create(realm, "Analyser node minDecibels greater than maxDecibels"_string); @@ -317,6 +314,7 @@ WebIDL::ExceptionOr> AnalyserNode::construct_impl(JS::Real // MUST initialize the AudioNode this, with context and options as arguments. auto node = realm.create(realm, context, options); + TRY(node->set_fft_size(options.fft_size)); // Default options for channel count and interpretation // https://webaudio.github.io/web-audio-api/#AnalyserNode diff --git a/Tests/LibWeb/Crash/WebAudio/AnalyserNode-previous-block-initialization.html b/Tests/LibWeb/Crash/WebAudio/AnalyserNode-previous-block-initialization.html new file mode 100644 index 000000000000..4269247659b2 --- /dev/null +++ b/Tests/LibWeb/Crash/WebAudio/AnalyserNode-previous-block-initialization.html @@ -0,0 +1,7 @@ + +