vcl/win/window/salframe.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 9b3729d63cbed7c343f6c68983a40d9fbf329958
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Nov 23 11:48:16 2022 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Nov 23 12:41:42 2022 +0100

    Avoid memory leak on PostMessageW failure
    
    In addition to leaking memory, the struct holds a couple of VclPtr,
    so would prevent destroying referenced windows.
    
    Change-Id: I258b5f32aca033a602d7b2805b33bd08ba637309
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143154
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 42c9a802c232..ad54e4f20dbb 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -1045,8 +1045,10 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* 
pGraphics )
 
 bool WinSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
 {
-    bool const ret = PostMessageW(mhWnd, SAL_MSG_USEREVENT, 0, 
reinterpret_cast<LPARAM>(pData.release()));
+    bool const ret = PostMessageW(mhWnd, SAL_MSG_USEREVENT, 0, 
reinterpret_cast<LPARAM>(pData.get()));
     SAL_WARN_IF(!ret, "vcl", "ERROR: PostMessage() failed!");
+    if (ret)
+        pData.release();
     return ret;
 }
 

Reply via email to