Commit 10fd90d7 authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Fix the check for client hints count

The number of client hints requested by origin can be as high as
blink::mojom::WebClientHintsType::kLast + 1.

Bug: 735518
Change-Id: I6b5f2552b1f55f01e9b9aff33ce1ff33af8f125c
Reviewed-on: https://chromium-review.googlesource.com/961539Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542967}
parent 003df7b7
...@@ -42,9 +42,13 @@ void ClientHintsObserver::PersistClientHints( ...@@ -42,9 +42,13 @@ void ClientHintsObserver::PersistClientHints(
if (!primary_url.is_valid() || !content::IsOriginSecure(primary_url)) if (!primary_url.is_valid() || !content::IsOriginSecure(primary_url))
return; return;
DCHECK(!client_hints.empty());
DCHECK_LE(client_hints.size(),
static_cast<size_t>(blink::mojom::WebClientHintsType::kLast) + 1);
if (client_hints.empty() || if (client_hints.empty() ||
client_hints.size() > client_hints.size() >
static_cast<int>(blink::mojom::WebClientHintsType::kLast)) { (static_cast<size_t>(blink::mojom::WebClientHintsType::kLast) + 1)) {
// Return early if the list does not have the right number of values. // Return early if the list does not have the right number of values.
// Persisting wrong number of values to the disk may cause errors when // Persisting wrong number of values to the disk may cause errors when
// reading them back in the future. // reading them back in the future.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment