blob: a8115a6741f854ef6e598295deb1b0dafb22f4d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
From ae21059c1d1aed902da40dd7502fbca9c5cf8e3f Mon Sep 17 00:00:00 2001
From: Daniel Cheng <dcheng@chromium.org>
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<Value::Dict>(&data_);
`data_` is the first member of `base::Value::Dict`, and so `&data_`
evaluates to a null pointer. `absl::get_if<T>()` 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;
|