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

Unified Diff: base/pickle.cc

Issue 601563003: Add Read/WriteSizeT() functions to the pickle layer, plus one consumer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test failure Created 6 years, 2 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 | « base/pickle.h ('k') | base/pickle_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.cc
diff --git a/base/pickle.cc b/base/pickle.cc
index 2d7a051b20077e20d86346867f414cb3ab961ea6..d461f413dfd2e68a6e97c9f15d5d97dc68faacb3 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -106,6 +106,16 @@ bool PickleIterator::ReadUInt64(uint64* result) {
return ReadBuiltinType(result);
}
+bool PickleIterator::ReadSizeT(size_t* result) {
+ // Always read size_t as a 64-bit value to ensure compatibility between 32-bit
+ // and 64-bit processes.
+ uint64 result_uint64 = 0;
+ bool success = ReadBuiltinType(&result_uint64);
+ *result = static_cast<size_t>(result_uint64);
+ // Fail if the cast above truncates the value.
+ return success && (*result == result_uint64);
+}
+
bool PickleIterator::ReadFloat(float* result) {
// crbug.com/315213
// The source data may not be properly aligned, and unaligned float reads
« no previous file with comments | « base/pickle.h ('k') | base/pickle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698