Changeset 248963 in webkit


Ignore:
Timestamp:
Aug 21, 2019 2:30:03 PM (5 years ago)
Author:
Chris Dumez
Message:

Have NetworkCache::store() null check its completion handler before calling it
https://bugs.webkit.org/show_bug.cgi?id=200994

Reviewed by Geoffrey Garen.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::retrieveCacheEntry):
Stop passing nullptr for the completion handler now that the parameter has a default value.
Note that passing nullptr here was likely wrong since the NetworkCache::store() implementation
did not null-check the completion handler before calling it.

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::store):
Have NetworkCache::store() null check its completion handler before calling it as calling
a null WTF::Function crashes.

  • NetworkProcess/cache/NetworkCache.h:

Use nullptr as default parameter value for the completion handler.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248961 r248963  
     12019-08-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Have NetworkCache::store() null check its completion handler before calling it
     4        https://bugs.webkit.org/show_bug.cgi?id=200994
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * NetworkProcess/NetworkResourceLoader.cpp:
     9        (WebKit::NetworkResourceLoader::retrieveCacheEntry):
     10        Stop passing nullptr for the completion handler now that the parameter has a default value.
     11        Note that passing nullptr here was likely wrong since the NetworkCache::store() implementation
     12        did not null-check the completion handler before calling it.
     13
     14        * NetworkProcess/cache/NetworkCache.cpp:
     15        (WebKit::NetworkCache::Cache::store):
     16        Have NetworkCache::store() null check its completion handler before calling it as calling
     17        a null WTF::Function crashes.
     18
     19        * NetworkProcess/cache/NetworkCache.h:
     20        Use nullptr as default parameter value for the completion handler.
     21
    1222019-08-21  Rob Buis  <rbuis@igalia.com>
    223
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r248961 r248963  
    232232                auto cacheEntry = m_cache->makeEntry(request, entry->response, buffer.copyRef());
    233233                retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request });
    234                 m_cache->store(request, entry->response, WTFMove(buffer), nullptr);
     234                m_cache->store(request, entry->response, WTFMove(buffer));
    235235                return;
    236236            }
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp

    r248846 r248963  
    416416        }
    417417#endif
    418         completionHandler(mappedBody);
     418        if (completionHandler)
     419            completionHandler(mappedBody);
    419420        LOG(NetworkCache, "(NetworkProcess) stored");
    420421    });
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h

    r248713 r248963  
    116116    using RetrieveCompletionHandler = Function<void(std::unique_ptr<Entry>, const RetrieveInfo&)>;
    117117    void retrieve(const WebCore::ResourceRequest&, const GlobalFrameID&, RetrieveCompletionHandler&&);
    118     std::unique_ptr<Entry> store(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, RefPtr<WebCore::SharedBuffer>&&, Function<void(MappedBody&)>&&);
     118    std::unique_ptr<Entry> store(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, RefPtr<WebCore::SharedBuffer>&&, Function<void(MappedBody&)>&& = nullptr);
    119119    std::unique_ptr<Entry> storeRedirect(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, const WebCore::ResourceRequest& redirectRequest, Optional<Seconds> maxAgeCap);
    120120    std::unique_ptr<Entry> update(const WebCore::ResourceRequest&, const GlobalFrameID&, const Entry&, const WebCore::ResourceResponse& validatingResponse);
Note: See TracChangeset for help on using the changeset viewer.