Changeset 181453 in webkit


Ignore:
Timestamp:
Mar 12, 2015, 1:37:13 PM (10 years ago)
Author:
ggaren@apple.com
Message:

REGRESSION: Crash under Heap::reportExtraMemoryAllocatedSlowCase for media element
https://bugs.webkit.org/show_bug.cgi?id=142636

Reviewed by Mark Hahnenberg.

This was a pre-existing bug that I made a lot worse in
<https://trac.webkit.org/changeset/181411>.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute): Compare size before
subtracting rather than subtracting and then comparing to zero. The
latter technique is not valid for unsigned integers, which will happily
underflow into giant numbers.

  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::reportExtraMemoryAllocated): This code was

technically correct, but I took the opportunity to clean it up a bit.
There's no need to do two checks here, and it smells bad to check for
a negative unsigned integer.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181449 r181453  
     12015-03-12  Geoffrey Garen  <ggaren@apple.com>
     2
     3        REGRESSION: Crash under Heap::reportExtraMemoryAllocatedSlowCase for media element
     4        https://bugs.webkit.org/show_bug.cgi?id=142636
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        This was a pre-existing bug that I made a lot worse in
     9        <https://trac.webkit.org/changeset/181411>.
     10
     11        * html/HTMLMediaElement.cpp:
     12        (WebCore::HTMLMediaElement::parseAttribute): Compare size before
     13        subtracting rather than subtracting and then comparing to zero. The
     14        latter technique is not valid for unsigned integers, which will happily
     15        underflow into giant numbers.
     16
     17        * Modules/mediasource/SourceBuffer.cpp:
     18        (WebCore::SourceBuffer::reportExtraMemoryAllocated): This code was
     19         technically correct, but I took the opportunity to clean it up a bit.
     20         There's no need to do two checks here, and it smells bad to check for
     21         a negative unsigned integer.
     22
    1232015-03-12  Sebastian Dröge  <sebastian@centricular.com>
    224
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r181411 r181453  
    19921992{
    19931993    size_t extraMemoryCost = this->extraMemoryCost();
    1994     if (extraMemoryCost < m_reportedExtraMemoryCost)
     1994    if (extraMemoryCost <= m_reportedExtraMemoryCost)
    19951995        return;
    19961996
     
    19991999
    20002000    JSC::JSLockHolder lock(scriptExecutionContext()->vm());
    2001     if (extraMemoryCostDelta > 0) {
    2002         // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
    2003         // https://bugs.webkit.org/show_bug.cgi?id=142595
    2004         scriptExecutionContext()->vm().heap.deprecatedReportExtraMemory(extraMemoryCostDelta);
    2005     }
     2001    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
     2002    // https://bugs.webkit.org/show_bug.cgi?id=142595
     2003    scriptExecutionContext()->vm().heap.deprecatedReportExtraMemory(extraMemoryCostDelta);
    20062004}
    20072005
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r181423 r181453  
    634634
    635635        if (m_player) {
    636             JSC::VM& vm = JSDOMWindowBase::commonVM();
    637             JSC::JSLockHolder lock(vm);
    638 
    639636            size_t extraMemoryCost = m_player->extraMemoryCost();
    640             size_t extraMemoryCostDelta = extraMemoryCost - m_reportedExtraMemoryCost;
    641             m_reportedExtraMemoryCost = extraMemoryCost;
    642 
    643             if (extraMemoryCostDelta > 0) {
     637            if (extraMemoryCost > m_reportedExtraMemoryCost) {
     638                JSC::VM& vm = JSDOMWindowBase::commonVM();
     639                JSC::JSLockHolder lock(vm);
     640
     641                size_t extraMemoryCostDelta = extraMemoryCost - m_reportedExtraMemoryCost;
     642                m_reportedExtraMemoryCost = extraMemoryCost;
    644643                // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
    645644                // https://bugs.webkit.org/show_bug.cgi?id=142595
Note: See TracChangeset for help on using the changeset viewer.