OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/public/cpp/bindings/lib/validation_context.h" | 5 #include "mojo/public/cpp/bindings/lib/validation_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 ValidationContext::ValidationContext(const void* data, | 12 ValidationContext::ValidationContext(const void* data, |
13 size_t data_num_bytes, | 13 size_t data_num_bytes, |
14 size_t num_handles, | 14 size_t num_handles, |
15 Message* message, | 15 Message* message, |
16 const base::StringPiece& description) | 16 const base::StringPiece& description, |
| 17 int stack_depth) |
17 : message_(message), | 18 : message_(message), |
18 description_(description), | 19 description_(description), |
19 data_begin_(reinterpret_cast<uintptr_t>(data)), | 20 data_begin_(reinterpret_cast<uintptr_t>(data)), |
20 data_end_(data_begin_ + data_num_bytes), | 21 data_end_(data_begin_ + data_num_bytes), |
21 handle_begin_(0), | 22 handle_begin_(0), |
22 handle_end_(static_cast<uint32_t>(num_handles)) { | 23 handle_end_(static_cast<uint32_t>(num_handles)), |
| 24 stack_depth_(stack_depth) { |
23 if (data_end_ < data_begin_) { | 25 if (data_end_ < data_begin_) { |
24 // The calculation of |data_end_| overflowed. | 26 // The calculation of |data_end_| overflowed. |
25 // It shouldn't happen but if it does, set the range to empty so | 27 // It shouldn't happen but if it does, set the range to empty so |
26 // IsValidRange() and ClaimMemory() always fail. | 28 // IsValidRange() and ClaimMemory() always fail. |
27 NOTREACHED(); | 29 NOTREACHED(); |
28 data_end_ = data_begin_; | 30 data_end_ = data_begin_; |
29 } | 31 } |
30 if (handle_end_ < num_handles) { | 32 if (handle_end_ < num_handles) { |
31 // Assigning |num_handles| to |handle_end_| overflowed. | 33 // Assigning |num_handles| to |handle_end_| overflowed. |
32 // It shouldn't happen but if it does, set the handle index range to empty. | 34 // It shouldn't happen but if it does, set the handle index range to empty. |
33 NOTREACHED(); | 35 NOTREACHED(); |
34 handle_end_ = 0; | 36 handle_end_ = 0; |
35 } | 37 } |
36 } | 38 } |
37 | 39 |
38 ValidationContext::~ValidationContext() { | 40 ValidationContext::~ValidationContext() { |
39 } | 41 } |
40 | 42 |
41 } // namespace internal | 43 } // namespace internal |
42 } // namespace mojo | 44 } // namespace mojo |
OLD | NEW |