Changeset 53441 in webkit


Ignore:
Timestamp:
Jan 18, 2010 5:05:47 PM (14 years ago)
Author:
sfalken@apple.com
Message:

<https://bugs.webkit.org/show_bug.cgi?id=33816>
Crashes in Geolocation code due to refcounting, observer balance issues.

Reviewed by Sam Weinig.

Hold a ref to the GeoNotifier while dispatching a callback. The code was
copying a data member to avoid accessing a freed this ptr, but was still
using the this ptr.

Geolocation::removeObserver calls are not always balanced with addObserver.
Instead of asserting and continuing, don't try to remove non-existant
observers.

  • page/Geolocation.cpp:

(WebCore::Geolocation::GeoNotifier::timerFired): Protect notifier.

  • page/GeolocationController.cpp:

(WebCore::GeolocationController::removeObserver): Change ASSERT into an if with early return.

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53439 r53441  
     12010-01-18  Steve Falkenburg  <sfalken@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        <https://bugs.webkit.org/show_bug.cgi?id=33816>       
     6        Crashes in Geolocation code due to refcounting, observer balance issues.
     7       
     8        Hold a ref to the GeoNotifier while dispatching a callback. The code was
     9        copying a data member to avoid accessing a freed this ptr, but was still
     10        using the this ptr.
     11       
     12        Geolocation::removeObserver calls are not always balanced with addObserver.
     13        Instead of asserting and continuing, don't try to remove non-existant
     14        observers.
     15
     16        * page/Geolocation.cpp:
     17        (WebCore::Geolocation::GeoNotifier::timerFired): Protect notifier.
     18        * page/GeolocationController.cpp:
     19        (WebCore::GeolocationController::removeObserver): Change ASSERT into an if with early return.
     20
    1212010-01-18  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/WebCore/page/Geolocation.cpp

    r53342 r53441  
    108108    m_timer.stop();
    109109
    110     // Cache our pointer to the Geolocation object, as this GeoNotifier object
     110    // Protect this GeoNotifier object, since it
    111111    // could be deleted by a call to clearWatch in a callback.
    112     Geolocation* geolocation = m_geolocation;
     112    RefPtr<GeoNotifier> protect(this);
    113113
    114114    if (m_fatalError) {
     
    116116            m_errorCallback->handleEvent(m_fatalError.get());
    117117        // This will cause this notifier to be deleted.
    118         geolocation->fatalErrorOccurred(this);
     118        m_geolocation->fatalErrorOccurred(this);
    119119        return;
    120120    }
     
    124124        m_errorCallback->handleEvent(error.get());
    125125    }
    126     geolocation->requestTimedOut(this);
     126    m_geolocation->requestTimedOut(this);
    127127}
    128128
  • trunk/WebCore/page/GeolocationController.cpp

    r52103 r53441  
    5555void GeolocationController::removeObserver(Geolocation* observer)
    5656{
    57     ASSERT(m_observers.contains(observer));
     57    if (!m_observers.contains(observer))
     58        return;
    5859
    5960    m_observers.remove(observer);
Note: See TracChangeset for help on using the changeset viewer.