about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYechan Bae <yechan@gatech.edu>2021-03-20 13:42:54 -0400
committerYechan Bae <yechan@gatech.edu>2021-03-20 13:42:54 -0400
commit26a62701e42d10c03ce5f2f911e7d5edeefa2f0f (patch)
tree3fea1adf28791e850f233b6dc9e1fe3f8f0f8402
parent6d43225bfb08ec91f7476b76c7fec632c4a096ef (diff)
downloadrust-26a62701e42d10c03ce5f2f911e7d5edeefa2f0f.tar.gz
rust-26a62701e42d10c03ce5f2f911e7d5edeefa2f0f.zip
Update the comment
-rw-r--r--library/alloc/src/str.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs
index a7584c6b651..4d1e876457b 100644
--- a/library/alloc/src/str.rs
+++ b/library/alloc/src/str.rs
@@ -163,7 +163,7 @@ where
         })
         .expect("attempt to join into collection with len > usize::MAX");
 
-    // crucial for safety
+    // prepare an uninitialized buffer
     let mut result = Vec::with_capacity(reserved_len);
     debug_assert!(result.capacity() >= reserved_len);
 
@@ -178,9 +178,9 @@ where
         // massive improvements possible (~ x2)
         let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4);
 
-        // issue #80335: A weird borrow implementation can return different
-        // slices for the length calculation and the actual copy, so
-        // `remain.len()` might be non-zero.
+        // A weird borrow implementation may return different
+        // slices for the length calculation and the actual copy.
+        // Make sure we don't expose uninitialized bytes to the caller.
         let result_len = reserved_len - remain.len();
         result.set_len(result_len);
     }