Index: base/json/string_escape.cc |
diff --git a/base/json/string_escape.cc b/base/json/string_escape.cc |
index f67fa93bf2648191564eb1a77d46664036b1f41d..9a26ff76c4f4217c8637f2f44babaad0ddc190cd 100644 |
--- a/base/json/string_escape.cc |
+++ b/base/json/string_escape.cc |
@@ -91,7 +91,9 @@ bool EscapeJSONStringImpl(const S& str, bool put_in_quotes, std::string* dest) { |
for (int32_t i = 0; i < length; ++i) { |
uint32_t code_point; |
- if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point)) { |
+ if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point) || |
+ code_point == static_cast<decltype(code_point)>(CBU_SENTINEL) || |
+ !IsValidCharacter(code_point)) { |
code_point = kReplacementCodePoint; |
did_replacement = true; |
} |