diff options
author | zverre@yandex-team.ru <zverre@yandex-team.ru@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 03:18:59 +0000 |
---|---|---|
committer | zverre@yandex-team.ru <zverre@yandex-team.ru@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 03:18:59 +0000 |
commit | 0204a7873309bd43d22ef3cf5f6b55a401a518d4 (patch) | |
tree | 9809f79d6e93557cc9053274b2033e10647d56ab /chrome/browser/icon_manager.cc | |
parent | 149653c1ad1e4954fac3079e5b4cbfbee419ae71 (diff) | |
download | chromium_src-0204a7873309bd43d22ef3cf5f6b55a401a518d4.zip chromium_src-0204a7873309bd43d22ef3cf5f6b55a401a518d4.tar.gz chromium_src-0204a7873309bd43d22ef3cf5f6b55a401a518d4.tar.bz2 |
Fixed memory leak in icon_manager
When there is an entry in the cache and the |result| is NULL we put NULL in
the cache without deleting current entry. Also I offer to simplify logic
and to dissalow NULLs to reside in the cache. This does not affect any current
code.
BUG=
Review URL: https://codereview.chromium.org/27529002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230614 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/icon_manager.cc')
-rw-r--r-- | chrome/browser/icon_manager.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chrome/browser/icon_manager.cc b/chrome/browser/icon_manager.cc index 6c7f9fc..d0e2cbc 100644 --- a/chrome/browser/icon_manager.cc +++ b/chrome/browser/icon_manager.cc @@ -107,17 +107,21 @@ bool IconManager::OnImageLoaded( const ClientRequest& client_request = rit->second; - // Cache the bitmap. Watch out: |result| or the cached bitmap may be NULL to - // indicate a current or past failure. + // Cache the bitmap. Watch out: |result| may be NULL to indicate a current + // failure. We assume that if we have an entry in |icon_cache_| + // it must not be NULL. CacheKey key(group, client_request.size); IconMap::iterator it = icon_cache_.find(key); - if (it != icon_cache_.end() && result && it->second) { - if (it->second != result) { + if (it != icon_cache_.end()) { + if (!result) { + delete it->second; + icon_cache_.erase(it); + } else if (result != it->second) { it->second->SwapRepresentations(result); delete result; result = it->second; } - } else { + } else if (result) { icon_cache_[key] = result; } |