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

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

Issue 293983026: Mojo cpp bindings: remove redundant validation in Decode*(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: mojo/public/cpp/bindings/lib/bindings_serialization.cc
diff --git a/mojo/public/cpp/bindings/lib/bindings_serialization.cc b/mojo/public/cpp/bindings/lib/bindings_serialization.cc
index 6f5fa3ded0dca33e9eefc13d8b02bc6c340e86e6..c1114c0edba51df01430f408915b7141ddca37e0 100644
--- a/mojo/public/cpp/bindings/lib/bindings_serialization.cc
+++ b/mojo/public/cpp/bindings/lib/bindings_serialization.cc
@@ -60,17 +60,6 @@ bool ValidateEncodedPointer(const uint64_t* offset) {
reinterpret_cast<uintptr_t>(offset);
}
-bool ValidatePointer(const void* ptr, const Message& message) {
- const uint8_t* data = static_cast<const uint8_t*>(ptr);
- if (reinterpret_cast<uintptr_t>(data) % 8 != 0)
- return false;
-
- const uint8_t* data_start = message.data();
- const uint8_t* data_end = data_start + message.data_num_bytes();
-
- return data >= data_start && data < data_end;
-}
-
void EncodeHandle(Handle* handle, std::vector<Handle>* handles) {
if (handle->is_valid()) {
handles->push_back(*handle);
@@ -80,16 +69,14 @@ void EncodeHandle(Handle* handle, std::vector<Handle>* handles) {
}
}
-bool DecodeHandle(Handle* handle, std::vector<Handle>* handles) {
+void DecodeHandle(Handle* handle, std::vector<Handle>* handles) {
if (handle->value() == kEncodedInvalidHandleValue) {
*handle = Handle();
- return true;
+ return;
}
- if (handle->value() >= handles->size())
- return false;
+ assert(handle->value() < handles->size());
// Just leave holes in the vector so we don't screw up other indices.
*handle = FetchAndReset(&handles->at(handle->value()));
- return true;
}
bool ValidateStructHeader(const void* data,

Powered by Google App Engine
This is Rietveld 408576698