@@ -42,7 +42,8 @@ enum RightAlignMode {
42
42
static ALIGNED (16 ) u8 tail_magic[kShadowAlignment - 1];
43
43
44
44
bool HwasanChunkView::IsAllocated () const {
45
- return metadata_ && metadata_->alloc_context_id && metadata_->requested_size ;
45
+ return metadata_ && metadata_->alloc_context_id &&
46
+ metadata_->get_requested_size ();
46
47
}
47
48
48
49
// Aligns the 'addr' right to the granule boundary.
@@ -54,14 +55,14 @@ static uptr AlignRight(uptr addr, uptr requested_size) {
54
55
55
56
uptr HwasanChunkView::Beg () const {
56
57
if (metadata_ && metadata_->right_aligned )
57
- return AlignRight (block_, metadata_->requested_size );
58
+ return AlignRight (block_, metadata_->get_requested_size () );
58
59
return block_;
59
60
}
60
61
uptr HwasanChunkView::End () const {
61
62
return Beg () + UsedSize ();
62
63
}
63
64
uptr HwasanChunkView::UsedSize () const {
64
- return metadata_->requested_size ;
65
+ return metadata_->get_requested_size () ;
65
66
}
66
67
u32 HwasanChunkView::GetAllocStackId () const {
67
68
return metadata_->alloc_context_id ;
@@ -129,7 +130,7 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
129
130
}
130
131
Metadata *meta =
131
132
reinterpret_cast <Metadata *>(allocator.GetMetaData (allocated));
132
- meta->requested_size = static_cast < u32 > (orig_size);
133
+ meta->set_requested_size (orig_size);
133
134
meta->alloc_context_id = StackDepotPut (*stack);
134
135
meta->right_aligned = false ;
135
136
if (zeroise) {
@@ -191,7 +192,7 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
191
192
RoundDownTo (reinterpret_cast <uptr>(untagged_ptr), kShadowAlignment ));
192
193
Metadata *meta =
193
194
reinterpret_cast <Metadata *>(allocator.GetMetaData (aligned_ptr));
194
- uptr orig_size = meta->requested_size ;
195
+ uptr orig_size = meta->get_requested_size () ;
195
196
u32 free_context_id = StackDepotPut (*stack);
196
197
u32 alloc_context_id = meta->alloc_context_id ;
197
198
@@ -208,7 +209,7 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
208
209
orig_size, tail_magic);
209
210
}
210
211
211
- meta->requested_size = 0 ;
212
+ meta->set_requested_size ( 0 ) ;
212
213
meta->alloc_context_id = 0 ;
213
214
// This memory will not be reused by anyone else, so we are free to keep it
214
215
// poisoned.
@@ -245,8 +246,9 @@ static void *HwasanReallocate(StackTrace *stack, void *tagged_ptr_old,
245
246
void *untagged_ptr_old = UntagPtr (tagged_ptr_old);
246
247
Metadata *meta =
247
248
reinterpret_cast <Metadata *>(allocator.GetMetaData (untagged_ptr_old));
248
- internal_memcpy (UntagPtr (tagged_ptr_new), untagged_ptr_old,
249
- Min (new_size, static_cast <uptr>(meta->requested_size )));
249
+ internal_memcpy (
250
+ UntagPtr (tagged_ptr_new), untagged_ptr_old,
251
+ Min (new_size, static_cast <uptr>(meta->get_requested_size ())));
250
252
HwasanDeallocate (stack, tagged_ptr_old);
251
253
}
252
254
return tagged_ptr_new;
@@ -282,7 +284,7 @@ static uptr AllocationSize(const void *tagged_ptr) {
282
284
} else {
283
285
if (beg != untagged_ptr) return 0 ;
284
286
}
285
- return b->requested_size ;
287
+ return b->get_requested_size () ;
286
288
}
287
289
288
290
void *hwasan_malloc (uptr size, StackTrace *stack) {
0 commit comments