Bug 845960 - Fix a crash resulted from a missing nullcheck for the optional failure callback of decodeAudioData; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2013-03-04 23:04:51 -05:00
parent 1d1e78217e
commit 0d68519dd2
3 changed files with 25 additions and 2 deletions

View File

@ -868,8 +868,10 @@ WebAudioDecodeJob::OnFailure(ErrorCode aErrorCode)
// Ignore errors in calling the callback, since there is not much that we can
// do about it here.
ErrorResult rv;
mFailureCallback->Call(rv);
if (mFailureCallback) {
ErrorResult rv;
mFailureCallback->Call(rv);
}
mContext->RemoveFromDecodeQueue(this);
}

View File

@ -15,6 +15,7 @@ MOCHITEST_FILES := \
test_bug808374.html \
test_bug827541.html \
test_bug839753.html \
test_bug845960.html \
test_AudioBuffer.html \
test_AudioContext.html \
test_AudioListener.html \

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Crashtest for bug 845960</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
(new AudioContext()).decodeAudioData(new ArrayBuffer(0), function() {});
ok(true, "Should not crash when the optional failure callback is not specified");
SpecialPowers.clearUserPref("media.webaudio.enabled");
</script>
</pre>
</body>
</html>