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

Unified Diff: net/disk_cache/blockfile/rankings.cc

Issue 583293002: Do not leak when iterator outlives disk cache backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cacheenums-again
Patch Set: cleaner ownership Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/blockfile/rankings.cc
diff --git a/net/disk_cache/blockfile/rankings.cc b/net/disk_cache/blockfile/rankings.cc
index 7c93b431bcbbb8fd3cb1eba85e6dfb9e69ee3ef4..17e79913b133e33e1a9fce8afe1d8b7d8e369e4a 100644
--- a/net/disk_cache/blockfile/rankings.cc
+++ b/net/disk_cache/blockfile/rankings.cc
@@ -202,14 +202,16 @@ Rankings::ScopedRankingsBlock::ScopedRankingsBlock(
Rankings* rankings, CacheRankingsBlock* node)
: scoped_ptr<CacheRankingsBlock>(node), rankings_(rankings) {}
-Rankings::Iterator::Iterator(Rankings* rankings) {
+Rankings::Iterator::Iterator() {
memset(this, 0, sizeof(Iterator));
- my_rankings = rankings;
}
-Rankings::Iterator::~Iterator() {
- for (int i = 0; i < 3; i++)
- ScopedRankingsBlock(my_rankings, nodes[i]);
+void Rankings::Iterator::Reset() {
+ if (my_rankings) {
+ for (int i = 0; i < 3; i++)
+ ScopedRankingsBlock(my_rankings, nodes[i]);
+ }
+ memset(this, 0, sizeof(Iterator));
}
Rankings::Rankings() : init_(false) {}
« net/disk_cache/blockfile/backend_impl.cc ('K') | « net/disk_cache/blockfile/rankings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698