Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui_windows: Fix use-after-free in power request reason string (#64001)
whitecat1331d2074f4e15d2
diff --git a/crates/gpui_windows/src/platform.rs b/crates/gpui_windows/src/platform.rsindex c8b4c92356b..9855667b90d 100644--- a/crates/gpui_windows/src/platform.rs+++ b/crates/gpui_windows/src/platform.rs@@ -116,6 +116,9 @@ impl WindowsPlatformState {struct PowerRequest {handle: HANDLE,+ // `PowerCreateRequest` retains a pointer into the reason string for the+ // lifetime of the handle, so the UTF-16 buffer must outlive the request.+ _reason: Vec<u16>,}unsafe impl Send for PowerRequest {}@@ -138,7 +141,10 @@ impl PowerRequest {.log_err();return Err(error).context("Failed to set the Windows power request");}- Ok(Self { handle })+ Ok(Self {+ handle,+ _reason: reason,+ })}}