Commit b667e1c5 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Check for null weak ptr in ServiceWorkerScriptCacheMap.

context_ can be null.

No test added since there's no script cache map unittest.

Bug: 877360
Change-Id: Ib95d89255b0706d13cb784d812cb984903aa0c4a
Reviewed-on: https://chromium-review.googlesource.com/1188007
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585737}
parent 5fe74f83
...@@ -92,12 +92,18 @@ void ServiceWorkerScriptCacheMap::WriteMetadata( ...@@ -92,12 +92,18 @@ void ServiceWorkerScriptCacheMap::WriteMetadata(
const GURL& url, const GURL& url,
const std::vector<uint8_t>& data, const std::vector<uint8_t>& data,
const net::CompletionCallback& callback) { const net::CompletionCallback& callback) {
if (!context_) {
callback.Run(net::ERR_ABORTED);
return;
}
ResourceMap::iterator found = resource_map_.find(url); ResourceMap::iterator found = resource_map_.find(url);
if (found == resource_map_.end() || if (found == resource_map_.end() ||
found->second.resource_id == kInvalidServiceWorkerResourceId) { found->second.resource_id == kInvalidServiceWorkerResourceId) {
callback.Run(net::ERR_FILE_NOT_FOUND); callback.Run(net::ERR_FILE_NOT_FOUND);
return; return;
} }
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(data.size())); scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(data.size()));
if (data.size()) if (data.size())
memmove(buffer->data(), &data[0], data.size()); memmove(buffer->data(), &data[0], data.size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment