From 57f1fe49f80097adebb7ca99541f3e4471eb20ca Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 8 Mar 2013 12:29:00 -0500 Subject: [PATCH] Bug 849230 - Limit the range of sample rates accepted by AudioContext.createBuffer according to the spec; r=padenot --- content/media/webaudio/AudioContext.cpp | 5 +++++ content/media/webaudio/test/test_AudioBuffer.html | 9 +++++++++ content/media/webaudio/test/test_bug808374.html | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/content/media/webaudio/AudioContext.cpp b/content/media/webaudio/AudioContext.cpp index fadb11af4bf1..7798666ef860 100644 --- a/content/media/webaudio/AudioContext.cpp +++ b/content/media/webaudio/AudioContext.cpp @@ -79,6 +79,11 @@ AudioContext::CreateBuffer(JSContext* aJSContext, uint32_t aNumberOfChannels, uint32_t aLength, float aSampleRate, ErrorResult& aRv) { + if (aSampleRate < 8000 || aSampleRate > 96000) { + aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); + return nullptr; + } + if (aLength > INT32_MAX) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return nullptr; diff --git a/content/media/webaudio/test/test_AudioBuffer.html b/content/media/webaudio/test/test_AudioBuffer.html index cd7112a915b5..6852123db886 100644 --- a/content/media/webaudio/test/test_AudioBuffer.html +++ b/content/media/webaudio/test/test_AudioBuffer.html @@ -7,6 +7,7 @@
+