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

Unified Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2418083002: Fix LinkStyle SRI check when against 0 sized resource. (Closed)
Patch Set: review Created 4 years, 2 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/LayoutTests/resources/empty.css ('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/HTMLLinkElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
index a27a6472c4f8e94e1e0fe0c212804be928e867b0..7b5cfd145bd2136c74b40fc4c2ef13be5512615f 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -434,19 +434,22 @@ void LinkStyle::setCSSStyleSheet(
ResourceIntegrityDisposition disposition =
cachedStyleSheet->integrityDisposition();
- DCHECK(disposition != ResourceIntegrityDisposition::NotChecked ||
- !cachedStyleSheet->sheetText().isNull());
-
if (disposition == ResourceIntegrityDisposition::NotChecked &&
!cachedStyleSheet->loadFailedOrCanceled()) {
- DCHECK(cachedStyleSheet->resourceBuffer());
- if (SubresourceIntegrity::CheckSubresourceIntegrity(
- *m_owner, cachedStyleSheet->resourceBuffer()->data(),
- cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
- *cachedStyleSheet))
- disposition = ResourceIntegrityDisposition::Passed;
- else
- disposition = ResourceIntegrityDisposition::Failed;
+ bool checkResult;
+
+ // cachedStyleSheet->resourceBuffer() can be nullptr on load success.
+ // If response size == 0.
+ const char* data = nullptr;
+ size_t size = 0;
+ if (cachedStyleSheet->resourceBuffer()) {
+ data = cachedStyleSheet->resourceBuffer()->data();
+ size = cachedStyleSheet->resourceBuffer()->size();
+ }
+ checkResult = SubresourceIntegrity::CheckSubresourceIntegrity(
yhirano 2016/10/17 02:10:32 How about defining |checkResult| here?
+ *m_owner, data, size, KURL(baseURL, href), *cachedStyleSheet);
+ disposition = checkResult ? ResourceIntegrityDisposition::Passed
+ : ResourceIntegrityDisposition::Failed;
// TODO(kouhei): Remove this const_cast crbug.com/653502
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/empty.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698