From a36e49fd8e6bdd1f5e887c43420802a80160a38f Mon Sep 17 00:00:00 2001 From: Vladimir Sadovnikov Date: Mon, 23 Dec 2024 00:35:16 +0300 Subject: [PATCH] Fixed warning when building with LTO --- src/main/x11/X11Window.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/x11/X11Window.cpp b/src/main/x11/X11Window.cpp index 677c631..30f9695 100644 --- a/src/main/x11/X11Window.cpp +++ b/src/main/x11/X11Window.cpp @@ -1402,10 +1402,11 @@ namespace lsp if (hWindow <= 0) return STATUS_BAD_STATE; - size_t n = width * height; - unsigned long *buffer = new unsigned long [n + 2]; + const size_t n = width * height; + unsigned long *buffer = reinterpret_cast(malloc(sizeof(unsigned long) * (n + 2))); if (buffer == NULL) return STATUS_NO_MEM; + lsp_finally { free(buffer); }; buffer[0] = width; buffer[1] = height; @@ -1419,11 +1420,9 @@ namespace lsp const x11_atoms_t &a = pX11Display->atoms(); XChangeProperty( - pX11Display->x11display(), hWindow, - a.X11__NET_WM_ICON, a.X11_XA_CARDINAL, 32, PropModeReplace, - reinterpret_cast(buffer), n + 2); - - delete [] buffer; // Drop buffer + pX11Display->x11display(), hWindow, + a.X11__NET_WM_ICON, a.X11_XA_CARDINAL, 32, PropModeReplace, + reinterpret_cast(buffer), n + 2); return STATUS_OK; }