Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: Source/core/fetch/MemoryCache.cpp

Issue 1142523002: MemoryCache::resourceForURL(): add argument validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 Resource* MemoryCache::resourceForURL(const KURL& resourceURL) 204 Resource* MemoryCache::resourceForURL(const KURL& resourceURL)
205 { 205 {
206 return resourceForURL(resourceURL, defaultCacheIdentifier()); 206 return resourceForURL(resourceURL, defaultCacheIdentifier());
207 } 207 }
208 208
209 Resource* MemoryCache::resourceForURL(const KURL& resourceURL, const String& cac heIdentifier) 209 Resource* MemoryCache::resourceForURL(const KURL& resourceURL, const String& cac heIdentifier)
210 { 210 {
211 ASSERT(WTF::isMainThread()); 211 ASSERT(WTF::isMainThread());
212 if (!resourceURL.isValid() || resourceURL.isNull())
213 return nullptr;
214 ASSERT(!cacheIdentifier.isNull());
212 ResourceMap* resources = m_resourceMaps.get(cacheIdentifier); 215 ResourceMap* resources = m_resourceMaps.get(cacheIdentifier);
213 if (!resources) 216 if (!resources)
214 return nullptr; 217 return nullptr;
215 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); 218 KURL url = removeFragmentIdentifierIfNeeded(resourceURL);
216 MemoryCacheEntry* entry = resources->get(url); 219 MemoryCacheEntry* entry = resources->get(url);
217 if (!entry) 220 if (!entry)
218 return nullptr; 221 return nullptr;
219 Resource* resource = entry->m_resource.get(); 222 Resource* resource = entry->m_resource.get();
220 if (resource && !resource->lock()) { 223 if (resource && !resource->lock()) {
221 ASSERT(!resource->hasClients()); 224 ASSERT(!resource->hasClients());
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr entResource->isPurgeable(), currentResource->wasPurged()); 851 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr entResource->isPurgeable(), currentResource->wasPurged());
849 852
850 current = current->m_previousInAllResourcesList; 853 current = current->m_previousInAllResourcesList;
851 } 854 }
852 } 855 }
853 } 856 }
854 857
855 #endif // MEMORY_CACHE_STATS 858 #endif // MEMORY_CACHE_STATS
856 859
857 } // namespace blink 860 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698