Commit 08f761b8 authored by Alexandre Frechette's avatar Alexandre Frechette Committed by Commit Bot

Checking the validity of the string pointers returned by DictionaryValue.

Bug: 1024076
Change-Id: I1ca04cc7a1ee4513d6beece853ff132072b71c7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1924687Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: Alexandre Frechette <frechette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718695}
parent 3f01c246
......@@ -63,13 +63,17 @@ std::vector<std::string> UlpLanguageCodeLocator::GetLanguageCodes(
const bool is_cached =
celllangs_cached->GetDictionary(index, &celllang_cached);
const S2CellId cell_cached =
is_cached ? S2CellId::FromToken(
*celllang_cached->FindStringKey(kCellTokenKey))
: S2CellId::None();
if (cell_cached.is_valid() && cell_cached.contains(cell)) {
language = *celllang_cached->FindStringKey(kLanguageKey);
const std::string* token_cached =
is_cached ? celllang_cached->FindStringKey(kCellTokenKey) : nullptr;
const S2CellId cell_cached = token_cached != nullptr
? S2CellId::FromToken(*token_cached)
: S2CellId::None();
const std::string* lang_cached =
is_cached ? celllang_cached->FindStringKey(kLanguageKey) : nullptr;
if (cell_cached.is_valid() && cell_cached.contains(cell) &&
lang_cached != nullptr) {
language = *lang_cached;
} else {
const S2LangQuadTreeNode& root =
S2LangQuadTreeNode::Deserialize(serialized_langtrees_[index].get());
......
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