Skip to content

Commit f8cfc38

Browse files
committed
address nits
1 parent ec897f9 commit f8cfc38

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/memory.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
168168
pub fn reallocate(&mut self, ptr: Pointer, new_size: usize, align: usize) -> EvalResult<'tcx, Pointer> {
169169
// TODO(solson): Report error about non-__rust_allocate'd pointer.
170170
if ptr.offset != 0 {
171-
// TODO(solson): Report error about non-__rust_allocate'd pointer.
172171
return Err(EvalError::Unimplemented(format!("bad pointer offset: {}", ptr.offset)));
173172
}
174173
if ptr.points_to_zst() {
@@ -184,12 +183,11 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
184183
alloc.bytes.extend(iter::repeat(0).take(amount));
185184
alloc.undef_mask.grow(amount, false);
186185
} else if size > new_size {
187-
// it's possible to cause miri to use arbitrary amounts of memory that aren't detectable
188-
// through the memory_usage value, by allocating a lot and reallocating to zero
189186
self.memory_usage -= size - new_size;
190187
self.clear_relocations(ptr.offset(new_size as isize), size - new_size)?;
191188
let alloc = self.get_mut(ptr.alloc_id)?;
192189
alloc.bytes.truncate(new_size);
190+
alloc.bytes.shrink_to_fit();
193191
alloc.undef_mask.truncate(new_size);
194192
}
195193

0 commit comments

Comments
 (0)