Bug 864858 - Hold a reference to utterance before nsSpeechTask goes away in DispatchEndImpl() r=smaug
authorEitan Isaacson <eitan@monotonous.org>
Wed, 24 Apr 2013 09:49:35 -0700
changeset 140715 f87f14e8949faf0c40f219aeeacc00784f011918
parent 140714 5eeaecafb9896020e3ed7d9fc8ae41f6967322bb
child 140716 d7a0a407d1ce0ee1b774961a365aafda1ad7d7d5
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs864858
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 864858 - Hold a reference to utterance before nsSpeechTask goes away in DispatchEndImpl() r=smaug
content/media/webspeech/synth/nsSpeechTask.cpp
--- a/content/media/webspeech/synth/nsSpeechTask.cpp
+++ b/content/media/webspeech/synth/nsSpeechTask.cpp
@@ -258,24 +258,26 @@ nsSpeechTask::DispatchEndImpl(float aEla
   NS_ENSURE_FALSE(mUtterance->mState == SpeechSynthesisUtterance::STATE_ENDED,
                   NS_ERROR_NOT_AVAILABLE);
 
   // XXX: This should not be here, but it prevents a crash in MSG.
   if (mStream) {
     mStream->Destroy();
   }
 
+  nsRefPtr<SpeechSynthesisUtterance> utterance = mUtterance;
+
   if (mSpeechSynthesis) {
     mSpeechSynthesis->OnEnd(this);
   }
 
-  mUtterance->mState = SpeechSynthesisUtterance::STATE_ENDED;
-  mUtterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("end"),
-                                           aCharIndex, aElapsedTime,
-                                           NS_LITERAL_STRING(""));
+  utterance->mState = SpeechSynthesisUtterance::STATE_ENDED;
+  utterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("end"),
+                                          aCharIndex, aElapsedTime,
+                                          NS_LITERAL_STRING(""));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSpeechTask::DispatchPause(float aElapsedTime, uint32_t aCharIndex)
 {
   if (!mIndirectAudio) {
     NS_WARNING("Can't call DispatchPause() from a direct audio speech service");