From 3a13017edefca22584873b0dfd947bf3449c6223 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 2 Sep 2023 14:02:06 +0200 Subject: [PATCH] wind: Move more fallible operations before window creation --- wind/IPC.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wind/IPC.cpp b/wind/IPC.cpp index 50eb986e..98d93d68 100644 --- a/wind/IPC.cpp +++ b/wind/IPC.cpp @@ -11,6 +11,7 @@ auto _expr_rc = (expr); \ if (!_expr_rc.has_value()) \ { \ + g_windows.remove(window); \ delete window; \ os::IPC::send_error(client.conn, _expr_rc.error()); \ return {}; \ @@ -65,6 +66,8 @@ static Result handle_create_window_message(Client& client) auto name = TRY(String::from_cstring("Window")); + auto shm_path = TRY(String::format("/wind-shm-%d-%lu"_sv, client.conn.fd(), time(NULL))); + auto* window = new (std::nothrow) Window(request.rect, move(name), request.decorated); if (!window) { @@ -72,8 +75,6 @@ static Result handle_create_window_message(Client& client) return {}; } - auto shm_path = TRY_OR_IPC_ERROR(String::format("/wind-shm-%d-%lu"_sv, client.conn.fd(), time(NULL))); - window->pixels = (u32*)TRY_OR_IPC_ERROR( os::SharedMemory::create(shm_path.view(), window->contents.height * window->contents.width * 4));