Skip to content

Commit cb51e7d

Browse files
committed
Add comment explaining why buffer isn't overflowed
1 parent 8368d4f commit cb51e7d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/shims/env.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
137137
if (bytes.len() as u64) < size {
138138
// We add a `/0` terminator
139139
bytes.push(0);
140-
// This is ok because the buffer is larger than the path with the null terminator.
140+
// This is ok because the buffer was strictly larger than `bytes`, so after
141+
// adding the null terminator, the buffer size is larger or equal to
142+
// `bytes.len()`, meaning that `bytes` actually fit inside tbe buffer.
141143
this.memory_mut()
142144
.get_mut(buf.alloc_id)?
143145
.write_bytes(tcx, buf, &bytes)?;

0 commit comments

Comments
 (0)