From ae21059c1d1aed902da40dd7502fbca9c5cf8e3f Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Sat, 19 Feb 2022 21:38:32 -0800 Subject: [PATCH] Add missing null check in base::Value::Dict::FindByDottedPath() This happens to not crash through sheer luck most of the time. `GetIfDict()`'s implementation looks like: return absl::get_if(&data_); `data_` is the first member of `base::Value::Dict`, and so `&data_` evaluates to a null pointer. `absl::get_if()` returns `nullptr` if the input pointer is null, so it happens to silently (but incorrectly) work most of the time. Fixed: 1299245 Change-Id: I95ac65542b27f1ee0f7ce0bdec4575035a953820 (without unittest) --- diff --git a/base/values.cc b/base/values.cc index 25feea9..fcb00bf 100644 --- a/base/values.cc +++ b/base/values.cc @@ -608,6 +608,9 @@ if (!splitter.HasNext()) { return current_value; } + if (!current_value) { + return nullptr; + } current_dict = current_value->GetIfDict(); if (!current_dict) { return nullptr;