Skip to content

Commit c7fe5e9

Browse files
committed
Auto merge of #155813 - JonathanBrouwer:rollup-M9eCmdI, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #155774 (std: maintain `CStringArray` null-termination even if `Vec::push` panics) - #155810 (Expand the initialism UCRT in rustc book)
2 parents 68ffae4 + ea0a790 commit c7fe5e9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

library/std/src/sys/process/unix/common/cstring_array.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ impl CStringArray {
3535
/// Push an additional string to the array.
3636
pub fn push(&mut self, item: CString) {
3737
let argc = self.ptrs.len() - 1;
38-
// Replace the null pointer at the end of the array...
39-
self.ptrs[argc] = item.into_raw();
40-
// ... and recreate it to restore the data structure invariant.
38+
// Amend the array by another null pointer first, to ensure that the
39+
// array is null-terminated even when the `push` panics, in which case
40+
// the array will be left undisturbed (see #155748).
4141
self.ptrs.push(ptr::null());
42+
// Now, replace the previous null pointer.
43+
self.ptrs[argc] = item.into_raw();
4244
}
4345

4446
/// Returns a pointer to the C-string array managed by this type.

src/doc/rustc/src/platform-support/windows-gnullvm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Tier: 2 (with host tools)**
44

5-
Windows targets similar to `*-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of
5+
Windows targets similar to `*-windows-gnu` but using Universal C Runtime (UCRT) as the runtime and various LLVM tools/libraries instead of
66
GCC/Binutils.
77

88
Target triples available so far:

0 commit comments

Comments
 (0)