From b90d12c5fb3850f4ee55952a128b75710e9c0dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 12 Sep 2026 21:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=20Windows=20=E5=8E=9F?= =?UTF-8?q?=E5=AD=90=E6=9B=BF=E6=8D=A2=E5=AE=89=E5=85=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 记录 MoveFileExW 路径缓冲区的所有权、终止符和调用生命周期不变量。 --- .../src/ui_editor/commands/separation/persistence.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs index c27336066..7a4e44507 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/persistence.rs @@ -141,7 +141,7 @@ fn replace_separation_state_atomically(temporary: &Path, target: &Path) -> std:: fn replace_separation_state_atomically(temporary: &Path, target: &Path) -> std::io::Result<()> { use std::os::windows::ffi::OsStrExt; use windows_sys::Win32::Storage::FileSystem::{ - MOVEFILE_REPLACE_EXISTING, MOVEFILE_WRITE_THROUGH, MoveFileExW, + MoveFileExW, MOVEFILE_REPLACE_EXISTING, MOVEFILE_WRITE_THROUGH, }; let source = temporary @@ -154,6 +154,8 @@ fn replace_separation_state_atomically(temporary: &Path, target: &Path) -> std:: .encode_wide() .chain(std::iter::once(0)) .collect::>(); + // SAFETY: both buffers are owned, UTF-16 encoded, and NUL-terminated; they + // remain alive for the duration of the call, which only reads the paths. let moved = unsafe { MoveFileExW( source.as_ptr(),