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 |