From bab4983f6c73ad01da826defc169097f484c08b7 Mon Sep 17 00:00:00 2001 From: joboet Date: Sat, 25 Apr 2026 15:17:36 +0200 Subject: [PATCH 1/2] std: maintain `CStringArray` null-termination even if `Vec::push` panics --- library/std/src/sys/process/unix/common/cstring_array.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys/process/unix/common/cstring_array.rs b/library/std/src/sys/process/unix/common/cstring_array.rs index 1c840a85df9b..c2a3fcf67752 100644 --- a/library/std/src/sys/process/unix/common/cstring_array.rs +++ b/library/std/src/sys/process/unix/common/cstring_array.rs @@ -35,10 +35,12 @@ pub fn write(&mut self, index: usize, item: CString) { /// Push an additional string to the array. pub fn push(&mut self, item: CString) { let argc = self.ptrs.len() - 1; - // Replace the null pointer at the end of the array... - self.ptrs[argc] = item.into_raw(); - // ... and recreate it to restore the data structure invariant. + // Amend the array by another null pointer first, to ensure that the + // array is null-terminated even when the `push` panics, in which case + // the array will be left undisturbed (see #155748). self.ptrs.push(ptr::null()); + // Now, replace the previous null pointer. + self.ptrs[argc] = item.into_raw(); } /// Returns a pointer to the C-string array managed by this type. From 33c1e869d7d8fa01e4133e057cdacb07428b91d1 Mon Sep 17 00:00:00 2001 From: Miikka Salminen Date: Sun, 26 Apr 2026 09:05:37 +0300 Subject: [PATCH 2/2] Expand the initialism UCRT in rustc book This commit expands the initialism UCRT on first use in the rusct book chapter on the *-windows-gnullvm platform support, making the chapter easier to understand. Microsoft, the originator of this technology in Windows, expands it to Universal C Runtime[1]. The same expansion is added to the chapter. [1] https://learn.microsoft.com/en-us/cpp/porting/upgrade-your-code-to-the-universal-crt --- src/doc/rustc/src/platform-support/windows-gnullvm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/windows-gnullvm.md b/src/doc/rustc/src/platform-support/windows-gnullvm.md index e5db656e89f7..fccde2da99f5 100644 --- a/src/doc/rustc/src/platform-support/windows-gnullvm.md +++ b/src/doc/rustc/src/platform-support/windows-gnullvm.md @@ -2,7 +2,7 @@ **Tier: 2 (with host tools)** -Windows targets similar to `*-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of +Windows targets similar to `*-windows-gnu` but using Universal C Runtime (UCRT) as the runtime and various LLVM tools/libraries instead of GCC/Binutils. Target triples available so far: