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. 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: