Changeset 228975 in webkit


Ignore:
Timestamp:
Feb 24, 2018 2:06:39 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Null-dereference of the second argument resource of DocumentLoader::scheduleSubstituteResourceLoad
https://bugs.webkit.org/show_bug.cgi?id=182920

Patch by Fujii Hironori <Fujii Hironori> on 2018-02-24
Reviewed by Darin Adler.

A test case
imported/w3c/web-platform-tests/html/browsers/offline/appcache/workers/appcache-worker.html
always crashes due to a null-dereference if compiled and optimized
by GCC 7.2. The second argument resource of
DocumentLoader::scheduleSubstituteResourceLoad can be null if the
resource can't be found in cache. I guess GCC optimizes inline
HashMap::add based on assuming the resource never becomes null
because its type is SubstituteResource&.

This changes introduces a new method
DocumentLoader::scheduleCannotShowURLError because it looks tricky
to pass a nullptr to the second argument of
scheduleSubstituteResourceLoad.

No new tests (Covered by existing tests).

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::scheduleCannotShowURLError): Added a new method.

  • loader/DocumentLoader.h:
  • loader/appcache/ApplicationCacheHost.cpp:

(WebCore::ApplicationCacheHost::maybeLoadResource):
Call scheduleCannotShowURLError if the resource not found in the appcache.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228974 r228975  
     12018-02-24  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Null-dereference of the second argument `resource` of DocumentLoader::scheduleSubstituteResourceLoad
     4        https://bugs.webkit.org/show_bug.cgi?id=182920
     5
     6        Reviewed by Darin Adler.
     7
     8        A test case
     9        imported/w3c/web-platform-tests/html/browsers/offline/appcache/workers/appcache-worker.html
     10        always crashes due to a null-dereference if compiled and optimized
     11        by GCC 7.2. The second argument `resource` of
     12        DocumentLoader::scheduleSubstituteResourceLoad can be null if the
     13        resource can't be found in cache. I guess GCC optimizes inline
     14        HashMap::add based on assuming the `resource` never becomes null
     15        because its type is SubstituteResource&.
     16
     17        This changes introduces a new method
     18        DocumentLoader::scheduleCannotShowURLError because it looks tricky
     19        to pass a nullptr to the second argument of
     20        scheduleSubstituteResourceLoad.
     21
     22        No new tests (Covered by existing tests).
     23
     24        * loader/DocumentLoader.cpp:
     25        (WebCore::DocumentLoader::scheduleCannotShowURLError): Added a new method.
     26        * loader/DocumentLoader.h:
     27        * loader/appcache/ApplicationCacheHost.cpp:
     28        (WebCore::ApplicationCacheHost::maybeLoadResource):
     29        Call scheduleCannotShowURLError if the resource not found in the appcache.
     30
    1312018-02-17  Darin Adler  <darin@apple.com>
    232
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r228892 r228975  
    14381438}
    14391439
     1440void DocumentLoader::scheduleCannotShowURLError(ResourceLoader& loader)
     1441{
     1442    m_pendingSubstituteResources.set(&loader, nullptr);
     1443    deliverSubstituteResourcesAfterDelay();
     1444}
     1445
    14401446void DocumentLoader::addResponse(const ResourceResponse& response)
    14411447{
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r227348 r228975  
    185185
    186186    void scheduleSubstituteResourceLoad(ResourceLoader&, SubstituteResource&);
     187    void scheduleCannotShowURLError(ResourceLoader&);
    187188
    188189    // Return the ArchiveResource for the URL only when loading an Archive
  • trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp

    r228892 r228975  
    183183        return false;
    184184
    185     m_documentLoader.scheduleSubstituteResourceLoad(loader, *resource);
     185    if (resource)
     186        m_documentLoader.scheduleSubstituteResourceLoad(loader, *resource);
     187    else
     188        m_documentLoader.scheduleCannotShowURLError(loader);
    186189    return true;
    187190}
Note: See TracChangeset for help on using the changeset viewer.