We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a3345d2 commit 0830af8Copy full SHA for 0830af8
1 file changed
runtime/core/hierarchical_allocator.h
@@ -60,13 +60,23 @@ class HierarchicalAllocator final {
60
uint32_t memory_id,
61
size_t offset_bytes,
62
size_t size_bytes) {
63
+ // Check for integer overflow in offset_bytes + size_bytes.
64
+ ET_CHECK_OR_RETURN_ERROR(
65
+ size_bytes <= SIZE_MAX - offset_bytes,
66
+ InvalidArgument,
67
+ "Integer overflow in offset_bytes (%" ET_PRIsize_t
68
+ ") + size_bytes (%" ET_PRIsize_t ")",
69
+ offset_bytes,
70
+ size_bytes);
71
+
72
ET_CHECK_OR_RETURN_ERROR(
73
memory_id < buffers_.size(),
74
InvalidArgument,
75
"id %" PRIu32 " >= %" ET_PRIsize_t,
76
memory_id,
77
buffers_.size());
78
Span<uint8_t> buffer = buffers_[memory_id];
79
80
81
offset_bytes + size_bytes <= buffer.size(),
82
MemoryAllocationFailed,
0 commit comments