From 169b4a77e738662a20dcfd7a002a42d7963891a1 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sat, 9 May 2020 00:36:41 +0300 Subject: [PATCH] [dom] Reorder some calls to improve memory safety. --- dom/media/webaudio/AudioBuffer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dom/media/webaudio/AudioBuffer.cpp b/dom/media/webaudio/AudioBuffer.cpp index e7eba2d48..e4252dfcf 100644 --- a/dom/media/webaudio/AudioBuffer.cpp +++ b/dom/media/webaudio/AudioBuffer.cpp @@ -254,8 +254,6 @@ void AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannelNumber, uint32_t aStartInChannel, ErrorResult& aRv) { - aDestination.ComputeLengthAndData(); - uint32_t length = aDestination.Length(); CheckedInt end = aStartInChannel; end += length; @@ -266,6 +264,7 @@ AudioBuffer::CopyFromChannel(const Float32Array& aDestination, uint32_t aChannel } JS::AutoCheckCannotGC nogc; + aDestination.ComputeLengthAndData(); JSObject* channelArray = mJSChannels[aChannelNumber]; const float* sourceData = nullptr; if (channelArray) { @@ -296,8 +295,6 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource, uint32_t aChannelNumber, uint32_t aStartInChannel, ErrorResult& aRv) { - aSource.ComputeLengthAndData(); - uint32_t length = aSource.Length(); CheckedInt end = aStartInChannel; end += length; @@ -320,6 +317,7 @@ AudioBuffer::CopyToChannel(JSContext* aJSContext, const Float32Array& aSource, return; } + aSource.ComputeLengthAndData(); bool isShared = false; float* channelData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc); // The channelData arrays should all have originated in