Changeset 246437 in webkit


Ignore:
Timestamp:
Jun 14, 2019 10:42:13 AM (5 years ago)
Author:
jer.noble@apple.com
Message:

CRASH(nullptr) in WebCore::jsAudioContextCurrentTime()
https://bugs.webkit.org/show_bug.cgi?id=198859
<rdar://problem/27986991>

Reviewed by Eric Carlson.

AudioContext's m_destinationNode can become null during iframe teardown,
but can AudioContext methods can still be called by JavaScript. Add null-checks
to all (remaing) unprotected dereferences of m_destinationNode.

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::uninitialize):
(WebCore::AudioContext::createBufferSource):
(WebCore::AudioContext::createScriptProcessor):
(WebCore::AudioContext::createBiquadFilter):
(WebCore::AudioContext::createPanner):
(WebCore::AudioContext::createConvolver):
(WebCore::AudioContext::createDynamicsCompressor):
(WebCore::AudioContext::createAnalyser):
(WebCore::AudioContext::createGain):
(WebCore::AudioContext::createDelay):
(WebCore::AudioContext::createChannelSplitter):
(WebCore::AudioContext::createChannelMerger):
(WebCore::AudioContext::createOscillator):

  • Modules/webaudio/AudioContext.h:

(WebCore::AudioContext::currentSampleFrame const):
(WebCore::AudioContext::currentTime const):
(WebCore::AudioContext::sampleRate const):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246436 r246437  
     12019-06-14  Jer Noble  <jer.noble@apple.com>
     2
     3        CRASH(nullptr) in WebCore::jsAudioContextCurrentTime()
     4        https://bugs.webkit.org/show_bug.cgi?id=198859
     5        <rdar://problem/27986991>
     6
     7        Reviewed by Eric Carlson.
     8
     9        AudioContext's m_destinationNode can become null during iframe teardown,
     10        but can AudioContext methods can still be called by JavaScript. Add null-checks
     11        to all (remaing) unprotected dereferences of m_destinationNode.
     12
     13        * Modules/webaudio/AudioContext.cpp:
     14        (WebCore::AudioContext::uninitialize):
     15        (WebCore::AudioContext::createBufferSource):
     16        (WebCore::AudioContext::createScriptProcessor):
     17        (WebCore::AudioContext::createBiquadFilter):
     18        (WebCore::AudioContext::createPanner):
     19        (WebCore::AudioContext::createConvolver):
     20        (WebCore::AudioContext::createDynamicsCompressor):
     21        (WebCore::AudioContext::createAnalyser):
     22        (WebCore::AudioContext::createGain):
     23        (WebCore::AudioContext::createDelay):
     24        (WebCore::AudioContext::createChannelSplitter):
     25        (WebCore::AudioContext::createChannelMerger):
     26        (WebCore::AudioContext::createOscillator):
     27        * Modules/webaudio/AudioContext.h:
     28        (WebCore::AudioContext::currentSampleFrame const):
     29        (WebCore::AudioContext::currentTime const):
     30        (WebCore::AudioContext::sampleRate const):
     31
    1322019-06-14  Youenn Fablet  <youenn@apple.com>
    233
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r245889 r246437  
    268268
    269269    // This stops the audio thread and all audio rendering.
    270     m_destinationNode->uninitialize();
     270    if (m_destinationNode)
     271        m_destinationNode->uninitialize();
    271272
    272273    // Don't allow the context to initialize a second time after it's already been explicitly uninitialized.
     
    442443
    443444    lazyInitialize();
    444     Ref<AudioBufferSourceNode> node = AudioBufferSourceNode::create(*this, m_destinationNode->sampleRate());
     445    Ref<AudioBufferSourceNode> node = AudioBufferSourceNode::create(*this, sampleRate());
    445446
    446447    // Because this is an AudioScheduledSourceNode, the context keeps a reference until it has finished playing.
     
    578579        return Exception { NotSupportedError };
    579580
    580     auto node = ScriptProcessorNode::create(*this, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels);
     581    auto node = ScriptProcessorNode::create(*this, sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels);
    581582
    582583    refNode(node); // context keeps reference until we stop making javascript rendering callbacks
     
    594595    lazyInitialize();
    595596
    596     return BiquadFilterNode::create(*this, m_destinationNode->sampleRate());
     597    return BiquadFilterNode::create(*this, sampleRate());
    597598}
    598599
     
    618619
    619620    lazyInitialize();
    620     return PannerNode::create(*this, m_destinationNode->sampleRate());
     621    return PannerNode::create(*this, sampleRate());
    621622}
    622623
     
    630631
    631632    lazyInitialize();
    632     return ConvolverNode::create(*this, m_destinationNode->sampleRate());
     633    return ConvolverNode::create(*this, sampleRate());
    633634}
    634635
     
    642643
    643644    lazyInitialize();
    644     return DynamicsCompressorNode::create(*this, m_destinationNode->sampleRate());
     645    return DynamicsCompressorNode::create(*this, sampleRate());
    645646}
    646647
     
    654655
    655656    lazyInitialize();
    656     return AnalyserNode::create(*this, m_destinationNode->sampleRate());
     657    return AnalyserNode::create(*this, sampleRate());
    657658}
    658659
     
    666667
    667668    lazyInitialize();
    668     return GainNode::create(*this, m_destinationNode->sampleRate());
     669    return GainNode::create(*this, sampleRate());
    669670}
    670671
     
    678679
    679680    lazyInitialize();
    680     return DelayNode::create(*this, m_destinationNode->sampleRate(), maxDelayTime);
     681    return DelayNode::create(*this, sampleRate(), maxDelayTime);
    681682}
    682683
     
    690691
    691692    lazyInitialize();
    692     auto node = ChannelSplitterNode::create(*this, m_destinationNode->sampleRate(), numberOfOutputs);
     693    auto node = ChannelSplitterNode::create(*this, sampleRate(), numberOfOutputs);
    693694    if (!node)
    694695        return Exception { IndexSizeError };
     
    705706
    706707    lazyInitialize();
    707     auto node = ChannelMergerNode::create(*this, m_destinationNode->sampleRate(), numberOfInputs);
     708    auto node = ChannelMergerNode::create(*this, sampleRate(), numberOfInputs);
    708709    if (!node)
    709710        return Exception { IndexSizeError };
     
    721722    lazyInitialize();
    722723
    723     Ref<OscillatorNode> node = OscillatorNode::create(*this, m_destinationNode->sampleRate());
     724    Ref<OscillatorNode> node = OscillatorNode::create(*this, sampleRate());
    724725
    725726    // Because this is an AudioScheduledSourceNode, the context keeps a reference until it has finished playing.
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.h

    r244977 r246437  
    109109
    110110    AudioDestinationNode* destination() { return m_destinationNode.get(); }
    111     size_t currentSampleFrame() const { return m_destinationNode->currentSampleFrame(); }
    112     double currentTime() const { return m_destinationNode->currentTime(); }
    113     float sampleRate() const { return m_destinationNode->sampleRate(); }
     111    size_t currentSampleFrame() const { return m_destinationNode ? m_destinationNode->currentSampleFrame() : 0; }
     112    double currentTime() const { return m_destinationNode ? m_destinationNode->currentTime() : 0.; }
     113    float sampleRate() const { return m_destinationNode ? m_destinationNode->sampleRate() : 0.f; }
    114114    unsigned long activeSourceCount() const { return static_cast<unsigned long>(m_activeSourceCount); }
    115115
Note: See TracChangeset for help on using the changeset viewer.