Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1574)

Unified Diff: mojo/public/cpp/bindings/lib/wtf_string_serialization.cc

Issue 1810253002: Mojo C++ bindings: fix sanity check of wtf string serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/wtf_string_serialization.cc
diff --git a/mojo/public/cpp/bindings/lib/wtf_string_serialization.cc b/mojo/public/cpp/bindings/lib/wtf_string_serialization.cc
index d1b749d210c01a709efce47dd5706de2074f8348..febd073ff5e0a098857ce60596f67b998199a23e 100644
--- a/mojo/public/cpp/bindings/lib/wtf_string_serialization.cc
+++ b/mojo/public/cpp/bindings/lib/wtf_string_serialization.cc
@@ -15,21 +15,20 @@
namespace WTF {
namespace {
-struct UTF8AdaptorWithPointer {
- explicit UTF8AdaptorWithPointer(const WTF::String& input)
- : utf8_adaptor(input) {
+struct UTF8AdaptorInfo {
+ explicit UTF8AdaptorInfo(const WTF::String& input) : utf8_adaptor(input) {
#if DCHECK_IS_ON()
- original_input = reinterpret_cast<uintptr_t>(&input);
+ original_size_in_bytes = static_cast<size_t>(input.sizeInBytes());
#endif
}
- ~UTF8AdaptorWithPointer() {}
+ ~UTF8AdaptorInfo() {}
WTF::StringUTF8Adaptor utf8_adaptor;
#if DCHECK_IS_ON()
- // For sanity check only. Never dereferenced.
- uintptr_t original_input;
+ // For sanity check only.
+ size_t original_size_in_bytes;
#endif
};
@@ -38,7 +37,7 @@ class WTFStringContextImpl : public mojo::internal::WTFStringContext {
WTFStringContextImpl() {}
~WTFStringContextImpl() override {}
- std::queue<UTF8AdaptorWithPointer>& utf8_adaptors() { return utf8_adaptors_; }
+ std::queue<UTF8AdaptorInfo>& utf8_adaptors() { return utf8_adaptors_; }
private:
// When serializing an object, we call GetSerializedSize_() recursively on
@@ -47,7 +46,7 @@ class WTFStringContextImpl : public mojo::internal::WTFStringContext {
// serialization. If some WTF::Strings need to be converted to UTF8, we don't
// want to do that twice. Therefore, we store a WTF::StringUTF8Adaptor for
// each in the first pass, and reuse it in the second pass.
- std::queue<UTF8AdaptorWithPointer> utf8_adaptors_;
+ std::queue<UTF8AdaptorInfo> utf8_adaptors_;
DISALLOW_COPY_AND_ASSIGN(WTFStringContextImpl);
};
@@ -87,8 +86,8 @@ void Serialize_(const WTF::String& input,
DCHECK(!utf8_adaptors.empty());
#if DCHECK_IS_ON()
- DCHECK_EQ(utf8_adaptors.front().original_input,
- reinterpret_cast<uintptr_t>(&input));
+ DCHECK_EQ(utf8_adaptors.front().original_size_in_bytes,
+ static_cast<size_t>(input.sizeInBytes()));
#endif
const WTF::StringUTF8Adaptor& adaptor = utf8_adaptors.front().utf8_adaptor;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698