git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit5cd239d92048f762a82b82898645470be78b0a57
parent5843deb9a4
authorLucas Galante <[email protected]>
date2026-08-13 00:32
fix: explicitly initialize last_saved_state_json in Server::default

Server::default zero-fills the struct with write_bytes and then ptr::writes
every field whose all-zero representation is not a valid value — which is why
the Vecs and Options are listed there. Option<String> happens to be sound when
zeroed (None via the null-pointer niche), but that is layout-dependent and the
surrounding code deliberately does not rely on it. Initialize it explicitly like
its neighbours.

Co-Authored-By: Claude Opus 5 <[email protected]>

 src/server/server.rs         | 1 +
 src/server/window_manager.rs | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/server/server.rs b/src/server/server.rs
index f335b0f..51e5f5e 100644
--- a/src/server/server.rs
+++ b/src/server/server.rs
@@ -878,6 +878,7 @@ impl Default for Server {
             std::ptr::write(&mut (*server.as_mut_ptr()).wm.startup, Vec::new());
             std::ptr::write(&mut (*server.as_mut_ptr()).wm.startup_pids, Vec::new());
             std::ptr::write(&mut (*server.as_mut_ptr()).wm.status_sender, None);
+            std::ptr::write(&mut (*server.as_mut_ptr()).wm.last_saved_state_json, None);
             std::ptr::write(&mut (*server.as_mut_ptr()).layer_shell.surfaces, crate::slotmap::SlotMap::new());
             std::ptr::write(&mut (*server.as_mut_ptr()).inspector, crate::inspector::Inspector::new());
             std::ptr::write(&mut (*server.as_mut_ptr()).cce_window_management, crate::cce_window_management::CceWindowManagement::new());
diff --git a/src/server/window_manager.rs b/src/server/window_manager.rs
index 5076563..cfe1c0b 100644
--- a/src/server/window_manager.rs
+++ b/src/server/window_manager.rs
@@ -121,7 +121,7 @@ pub struct WindowManager {
     /// serialization is byte-identical keeps the file exactly as current as
     /// before while making an idle session silent on disk. `None` until the
     /// first write, so a fresh start always writes once.
-    last_saved_state_json: Option<String>,
+    pub last_saved_state_json: Option<String>,
     /// One-shot placement hints (`place-next <app_id> <x> <y>` over IPC):
     /// the next map of a floating toplevel with this app_id lands near the
     /// given layout position instead of its remembered spot — widget-spawned