mirror of
https://github.com/serde-rs/json.git
synced 2025-09-30 14:32:05 +00:00
Add a safety comment to unsafe block
This commit is contained in:
parent
be2198a54d
commit
73011c0b2b
@ -977,6 +977,10 @@ fn push_wtf8_codepoint(n: u32, scratch: &mut Vec<u8>) {
|
||||
|
||||
scratch.reserve(4);
|
||||
|
||||
// SAFETY: After the `reserve` call, `scratch` has at least 4 bytes of allocated but
|
||||
// unintialized memory after its last initialized byte, which is where `ptr` points. All
|
||||
// reachable match arms write `encoded_len` bytes to that region and update the length
|
||||
// accordingly, and `encoded_len` is always <= 4.
|
||||
unsafe {
|
||||
let ptr = scratch.as_mut_ptr().add(scratch.len());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user