Skip to content

Commit 73011c0

Browse files
committed
Add a safety comment to unsafe block
1 parent be2198a commit 73011c0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/read.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,10 @@ fn push_wtf8_codepoint(n: u32, scratch: &mut Vec<u8>) {
977977

978978
scratch.reserve(4);
979979

980+
// SAFETY: After the `reserve` call, `scratch` has at least 4 bytes of allocated but
981+
// unintialized memory after its last initialized byte, which is where `ptr` points. All
982+
// reachable match arms write `encoded_len` bytes to that region and update the length
983+
// accordingly, and `encoded_len` is always <= 4.
980984
unsafe {
981985
let ptr = scratch.as_mut_ptr().add(scratch.len());
982986

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy