Index: third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc |
diff --git a/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc b/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc |
index 30786e396d01aa247aa02b1cb0fe586a7c61aad7..d79a6ee45007c99d7b2059d50b1ff37485a3138d 100644 |
--- a/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc |
+++ b/third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc |
@@ -511,10 +511,21 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st, |
// UTF-8 strings. Since UTF-8 validation is only used for debugging |
// anyway, we simply always return success if initialization hasn't |
// occurred yet. |
-extern bool cr_module_initialized_; |
+namespace { |
+ |
+bool module_initialized_ = false; |
+ |
+struct InitDetector { |
+ InitDetector() { |
+ module_initialized_ = true; |
+ } |
+}; |
+InitDetector init_detector; |
+ |
+} // namespace |
bool IsStructurallyValidUTF8(const char* buf, int len) { |
- if (!cr_module_initialized_) return true; |
+ if (!module_initialized_) return true; |
int bytes_consumed = 0; |
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj, |
@@ -523,7 +534,7 @@ bool IsStructurallyValidUTF8(const char* buf, int len) { |
} |
int UTF8SpnStructurallyValid(const StringPiece& str) { |
- if (!cr_module_initialized_) return str.size(); |
+ if (!module_initialized_) return str.size(); |
int bytes_consumed = 0; |
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj, |