Bug 1265394 - Handle infinite values in SetPosition and SetOrientation; r=padenot
Passing infinite values into an AudioParam will trigger an assert in debug
builds. Returning early here mimics the non-debug behaviour of refusing to
insert an event with an infinite value.
MozReview-Commit-ID: BaAtiAnh1s
--- a/dom/media/webaudio/PannerNode.h
+++ b/dom/media/webaudio/PannerNode.h
@@ -7,16 +7,17 @@
#ifndef PannerNode_h_
#define PannerNode_h_
#include "AudioNode.h"
#include "mozilla/dom/PannerNodeBinding.h"
#include "ThreeDPoint.h"
#include "mozilla/WeakPtr.h"
#include "WebAudioUtils.h"
+#include <limits>
#include <set>
namespace mozilla {
namespace dom {
class AudioContext;
class AudioBufferSourceNode;
@@ -64,24 +65,34 @@ public:
void SetDistanceModel(DistanceModelType aDistanceModel)
{
mDistanceModel = aDistanceModel;
SendInt32ParameterToStream(DISTANCE_MODEL, int32_t(mDistanceModel));
}
void SetPosition(double aX, double aY, double aZ)
{
+ if (fabs(aX) > std::numeric_limits<float>::max() ||
+ fabs(aY) > std::numeric_limits<float>::max() ||
+ fabs(aZ) > std::numeric_limits<float>::max()) {
+ return;
+ }
mPositionX->SetValue(aX);
mPositionY->SetValue(aY);
mPositionZ->SetValue(aZ);
SendThreeDPointParameterToStream(POSITION, ConvertAudioParamTo3DP(mPositionX, mPositionY, mPositionZ));
}
void SetOrientation(double aX, double aY, double aZ)
{
+ if (fabs(aX) > std::numeric_limits<float>::max() ||
+ fabs(aY) > std::numeric_limits<float>::max() ||
+ fabs(aZ) > std::numeric_limits<float>::max()) {
+ return;
+ }
mOrientationX->SetValue(aX);
mOrientationY->SetValue(aY);
mOrientationZ->SetValue(aZ);
SendThreeDPointParameterToStream(ORIENTATION, ConvertAudioParamTo3DP(mOrientationX, mOrientationY, mOrientationZ));
}
void SetVelocity(double aX, double aY, double aZ)
{