b=920987 check for ovrflw in addition r=ehsan

--HG--
extra : rebase_source : 759d416f4697bb60dd24b104678b6fb259ee308d
This commit is contained in:
Karl Tomlinson 2013-09-28 12:11:26 +12:00
Родитель d95776b1fb
Коммит 6a14cf69bf
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -11,6 +11,7 @@
#include "AudioSegment.h" #include "AudioSegment.h"
#include "AudioChannelFormat.h" #include "AudioChannelFormat.h"
#include "mozilla/PodOperations.h" #include "mozilla/PodOperations.h"
#include "mozilla/CheckedInt.h"
#include "AudioNodeEngine.h" #include "AudioNodeEngine.h"
namespace mozilla { namespace mozilla {
@ -113,8 +114,10 @@ AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannel
uint32_t aStartInChannel, ErrorResult& aRv) uint32_t aStartInChannel, ErrorResult& aRv)
{ {
uint32_t length = aDestination.Length(); uint32_t length = aDestination.Length();
CheckedInt<uint32_t> end = aStartInChannel;
end += length;
if (aChannelNumber >= NumberOfChannels() || if (aChannelNumber >= NumberOfChannels() ||
aStartInChannel + length >= mLength) { !end.isValid() || end.value() >= mLength) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return; return;
} }
@ -137,8 +140,10 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource,
ErrorResult& aRv) ErrorResult& aRv)
{ {
uint32_t length = aSource.Length(); uint32_t length = aSource.Length();
CheckedInt<uint32_t> end = aStartInChannel;
end += length;
if (aChannelNumber >= NumberOfChannels() || if (aChannelNumber >= NumberOfChannels() ||
aStartInChannel + length >= mLength) { !end.isValid() || end.value() >= mLength) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return; return;
} }