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

Unified Diff: third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp

Issue 1937033002: Fix crash in CSSStyleSheetResource::appendData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove client in destructor Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
index 19e8b68357cf27bd712ecd7bb63d734d2f68796a..6be45f8e9fd1e327855f9edae52571d88d84fa12 100644
--- a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
@@ -242,10 +242,22 @@ CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR
{
}
+void CSSPreloaderResourceClient::stopObserving()
+{
+ if (m_resource) {
+ m_resource->removeClient(this);
+ m_resource.clear();
+ }
+}
+
+CSSPreloaderResourceClient::~CSSPreloaderResourceClient()
+{
+ stopObserving();
Nate Chapin 2016/05/03 18:25:30 Alternately, you can have CSSPreloaderResourceClie
Charlie Harrison 2016/05/03 20:32:11 Very good point. Thanks for the suggestion.
+}
+
void CSSPreloaderResourceClient::notifyFinished(Resource* resource)
{
- resource->removeClient(this);
- m_resource.clear();
+ stopObserving();
}
// Only attach for one appendData call, as that's where most imports will likely
@@ -267,8 +279,7 @@ void CSSPreloaderResourceClient::didAppendFirstData(const CSSStyleSheetResource*
DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadScanner.ExternalCSS.PreloadCount", 1, 100, 50));
cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCount);
}
- m_resource->removeClient(this);
- m_resource.clear();
+ stopObserving();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698