We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents be2198a + 73011c0 commit 75ed447Copy full SHA for 75ed447
src/read.rs
@@ -977,6 +977,10 @@ fn push_wtf8_codepoint(n: u32, scratch: &mut Vec<u8>) {
977
978
scratch.reserve(4);
979
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.
984
unsafe {
985
let ptr = scratch.as_mut_ptr().add(scratch.len());
986
0 commit comments