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

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

Issue 1800753005: C++ bindings: A struct's Deserialize() now does validation before deserializing. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix char* - >char bug in unittest. FixedBuffer can accept sizes that aren't 8 byte multiples. 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 | « mojo/public/cpp/bindings/lib/fixed_buffer.h ('k') | mojo/public/cpp/bindings/lib/validation_errors.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/fixed_buffer.cc
diff --git a/mojo/public/cpp/bindings/lib/fixed_buffer.cc b/mojo/public/cpp/bindings/lib/fixed_buffer.cc
index c81fc6e8ed8bf70d7e6b325e6de8f8b994007c3d..44158c24cac12935954c43a989baca89840ff588 100644
--- a/mojo/public/cpp/bindings/lib/fixed_buffer.cc
+++ b/mojo/public/cpp/bindings/lib/fixed_buffer.cc
@@ -17,14 +17,14 @@ namespace internal {
FixedBuffer::FixedBuffer() : ptr_(nullptr), cursor_(0), size_(0) {}
void FixedBuffer::Initialize(void* memory, size_t size) {
- MOJO_DCHECK(size == internal::Align(size));
-
ptr_ = static_cast<char*>(memory);
cursor_ = 0;
size_ = size;
}
void* FixedBuffer::Allocate(size_t delta) {
+ // Ensure that all memory returned by Allocate() is 8-byte aligned w.r.t the
+ // start of the buffer.
delta = internal::Align(delta);
if (delta == 0 || delta > size_ - cursor_) {
« no previous file with comments | « mojo/public/cpp/bindings/lib/fixed_buffer.h ('k') | mojo/public/cpp/bindings/lib/validation_errors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698